首页 > 其他 > 详细

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

时间:2014-03-30 09:02:43      阅读:536      评论:0      收藏:0      [点我收藏+]

描述

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.

样例输入

3
7

样例输出

3
6
#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);
    }
}

TZU2014年省赛个人热身赛1 3741:Singlehood Number,布布扣,bubuko.com

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

原文:http://blog.csdn.net/libin56842/article/details/22533575

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!