Wednesday, February 9, 2011

10127 - Ones


#include<stdio.h>

int main()
{
    register int d,n,c;
    freopen("in.txt","r",stdin);

    while(scanf("%d",&d)==1)
    {
        n=c=1;
        if(d==1)
        {
            printf("1\n");
            continue;
        }
        while(n)
        {
            n=n*10+1;
            c++;
            n=n%d;
        }
        printf("%d\n",c);
    }
    return 0;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.