fjnu 1543 Ones

来源:互联网 发布:电脑网络不稳定老掉线 编辑:程序博客网 时间:2024/05/16 14:58

Description

Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n?

Input

Each line contains a number n.

Output

Output the number of digits.

Sample Input

3 7 9901

Sample Output

3612

 

KEY:给定一个n,看几个连续的1可以整除他;

 

Source:

#include
<iostream> 
using namespace std; 

int main() 
{    
    unsigned n, t, T; 
    
while(cin>>n) 
    

        t
=T=1
        t
%=n; 
        
while(t) 
        
{        
            t
=t*10+1
            T
++
            t
%=n; 
        }
 
        cout
<<T<<endl; 
    }
 
    
return 0
}