#include<bits/stdc++.h>
using namespace std;
int calculate(int input)
{
long int N=1;
int one=1,k;
while(1)
{
if(N<input)
{
N=N*10+1;
++one;
}
k=N%input;
if(k==0)
break;
else
N=k;
}
return one;
}
int main()
{
int N;
while(cin>>N)
cout<<calculate(N)<<endl;
return 0;
}
Monday, 10 April 2017
Subscribe to:
Post Comments (Atom)
-
Modular exponentiation: কন্টেস্ট প্রোগ্রামিংয়ে মডুলার এক্সপনেনটিয়েশন রিলেটেট প্রব্লেম মাঝে মাঝেই থাকে । বেশিরভাগ সময় নেইভ সল্যুশন করতে ...

No comments:
Post a Comment