... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Sunday, January 12, 2014

UVA-10127 :: Ones

//Problem link>>http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1068

#include <bits/stdc++.h>
using namespace std ;
int main ()
{
    long long  n , sum ,cnt ,i  ;
    while (cin>>n)
    {
        sum=0 ; cnt=0 ;
        for (i=0 ; ; i++)
        {
            sum=(sum*10+1)%n ;
            if (sum==0) break ;
            cnt++ ;
        }
        cout<<++cnt<<endl ;
    }

    return 0 ;
}

No comments:

Post a Comment