900B. Position in Fraction#分数位置(模拟)

题目出处:http://codeforces.com/problemset/problem/900/B

题目大意:找到一个数字在小数部分中第一次出现的位置

#include<iostream>
using namespace std;
int main(){
    int fz,fm,c,i=1;
    cin>>fz>>fm>>c;
    while(i<100005){
        fz*=10;
        if(fz/fm==c){cout<<i<<endl;return 0;}
        fz%=fm; i++;
    }
    cout<<"-1"<<endl;
    return 0;
}

题目就是简单的模拟,从十分位开始一位一位向后查询

posted @ 2017-12-17 14:19  hello_OK  阅读(213)  评论(0编辑  收藏  举报