#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
UVA 10127 solve
UVA 12372 solve
| #include<stdio.h> | |
| int main() | |
| { | |
| int i,T,L,W,H; | |
| int n=1; | |
| scanf("%d",&T); | |
| for(i=0;i<T;i++) | |
| { | |
| scanf("%d%d%d",&L,&W,&H); | |
| printf("case %d: ",n++); | |
| if(L<=20&W<=20&H<=20) | |
| printf("Good\n"); | |
| else | |
| printf("bad\n"); | |
| } | |
| return 0; | |
| } |
UVA 11728 solution
| #include<stdio.h> | |
| int main() | |
| { | |
| int a,b,c,T,i=1; | |
| scanf(“%d”,&T); | |
| while(i<=T) | |
| { | |
| scanf(“%d %d %d”,&a,&b,&c); | |
| if((a>b&&a<c)||(c<a&&a<b)) | |
| printf(“Case %d: %d\n”,i,a); | |
| if((b>a&&b<c)||(c<b&&b<a)) | |
| printf(“Case %d: %d\n”,i,b); | |
| if((c>a&&b>c)||(c>b&&a>c)) | |
| printf(“Case %d: %d\n”,i,c); | |
| i++; | |
| } | |
| return 0 |
Subscribe to:
Posts (Atom)
-
Modular exponentiation: কন্টেস্ট প্রোগ্রামিংয়ে মডুলার এক্সপনেনটিয়েশন রিলেটেট প্রব্লেম মাঝে মাঝেই থাকে । বেশিরভাগ সময় নেইভ সল্যুশন করতে ...
