Search found 3 matches

by SifatRuet12
Wed Jul 10, 2013 10:45 pm
Forum: Volume 108 (10800-10899)
Topic: 10812 - Beat the Spread!
Replies: 35
Views: 18664

Re: 10812 - Beat the Spread!

#include<stdio.h> int main() { int i,sum,t,a,b,dif; scanf("%d",&t); for(i=1;i<=t;i++){ scanf("%d %d",&sum,&dif); if(dif<=0 ||(dif+sum)%2==1 || sum<=0 || dif>sum) printf("impossible\n"); else { a=(dif+sum)/2; b=sum-a; if(a>=0 && b>=0){ if(a>b) printf("%d %d\n",a,b); else{printf("%d %d\n",b,a);}} } } ...
by SifatRuet12
Fri Jul 05, 2013 9:02 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 196561

Re: uva 100

Thank u for ur suggestion,accepted. @ Brianfry713
by SifatRuet12
Wed Jul 03, 2013 3:05 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 196561

uva 100

why does this code show compile error.I'm running it succesfully in codeblocks. #include<stdio.h> int m_cycle_len(int n) { int cnt=0; while(1) { if(n==1){ cnt++; break; } else if(n%2==0){ cnt++; n=n/2; } else if(n%2==1){ cnt++; n=n*3+1;} } return cnt; } int main() { unsigned int a,k,i,j,m; while(sca...

Go to advanced search