TZU2014年省赛个人热身赛1 3741:Singlehood Number

来源:互联网 发布:北京居住证 知乎 编辑:程序博客网 时间:2024/05/21 05:37

描述

Do you know 2011-11-11 is “Singlehood Festival”, and there is a kind of number which named “Singlehood Number”. “Singlehood Number” is a number which in decimal notation is a sequence of 1's.
Now given any integer 0 <= n <= 10000 not divisible by 2 or 5, find out a “Singlehood Number” which can be divided exactly by n. How many digits are in the smallest “Singlehood Number”?

输入

Each line contains a number n.

输出

For each n output the number of digits.

样例输入

37

样例输出

36
#include <stdio.h>#include <string.h>#include <algorithm>#include <queue>using namespace std;int main(){    int n;    while(~scanf("%d",&n))    {        int cnt = 1,s = 1;        while(s%n!=0)        {            s%=n;            s = s*10+1;            cnt++;        }        printf("%d\n",cnt);    }}

1 0
原创粉丝点击