zoukankan      html  css  js  c++  java
  • a/b c出现位置

    现有一式子 a / b. 你需要找出数字 c 在小数点后第一次出现的位置

    Input

    输入包含三个整数 a, b, c (1 ≤ a < b ≤ 105, 0 ≤ c ≤ 9).

    Output

    输出数字 c 第一次在小数点后出现的位置,如果 c 不在小数点后出现输出 -1

    Sample Input

    Input

    1 2 0
    

    Output

    2
    

    Input

    2 3 7
    

    Output

    -1

    Sample Output

    Hint

    第一组样例 : 1 / 2 = 0.5000(0) 出现在第二个位置

    第二组样例 : 2 / 3 = 0.6666(6) 7 没有出现,输出 -1

    当时方法不对,没做出来 下面是正确做法

    #include<stdio.h>
    #include <algorithm>
    #include <iostream>
    #include <string.h>
    #include <stdlib.h>
    using namespace std;
    int main()
    {
        long long int a,b,c,i,e,f;
        scanf("%lld%lld%lld",&a,&b,&c);
        for(i=0;i<100000;i++)
        {
            e=a*10/b;
            f=a*10%b;
            a=f;
            if(e==c)
            {
                printf("%d
    ",i+1);
                break;
            }
        }
        if(i>=100000)
            printf("-1
    ");
        return 0;
    }
  • 相关阅读:
    ryzen nvidia hackintosh
    mysql count 主键之坑
    git命令
    MYSQL 注释
    yaf twig配置
    1.YAF 的安装
    yaf nginx 设置
    ubuntu 16 阿里云 vsftpd
    win10下 homestead 安装
    活动调度
  • 原文地址:https://www.cnblogs.com/zcy19990813/p/9702767.html
Copyright © 2011-2022 走看看