info@sislbd.com +8801615 900004

UVA Online Judge

November 25, 2017

#include <stdio.h> #include <conio.h> int main() { long input1,input2,start,end,n,max; long count; while(scanf(“%ld%ld”,&input1,&input2)==2) { max=0; if(input1 >= input2) { start=input2; end=input1; } else { start=input1; end=input2; } for(long i=start;i<=end;i++) { count=0; n=i; while(1) { count=count+1; if(n==1) break; else if(n%2==0) n=n/2; else n=3*n+1; } // End of while if(count >= max) max=count; } // End of for

November 25, 2017

#include <stdio.h> int main() { int number,store,i,totalbricks,moves_bricks,set=0,avg; while(scanf(“%d”, &number) && number) { totalbricks=0; moves_bricks=0; set +=1; for(i=0;i<number;i++) { scanf(“%d”, &store); totalbricks += store; } // End of for avg=totalbricks/number; for(i=0;i<number;i++) if(avg > store) moves_bricks +=avg-store; printf(“Set #%d\n”,set); printf(“The minimum number of moves is %d.\n”,moves_bricks); printf(“\n”); } // End of while } // End of main

November 25, 2017

#include <stdio.h> int main() { int C,N,numbers,i,totalnumber,count; float avg,abovestudent; scanf(“%d”, &C); while(C >= 1) { scanf(“%d”, &N); totalnumber=0; for(i=0;i<N;i++) { scanf(“%d”, &numbers); totalnumber += numbers; } // End of for avg=(float)totalnumber/N; count=0; for(i=0;i<N;i++) if(avg < numbers) count += 1; abovestudent =(float)count*100/N; printf(“%.3f%c\n”,abovestudent,37); C -=1; }// End of while } // End of main

November 25, 2017

#include <stdio.h> int main() { int T,a,b,i,sum,j; scanf(“%d”, &T); j=1; while(T > 0) { sum=0; scanf(“%d%d”,&a,&b); for(i=a;i<=b;i++) { if(i%2!=0) sum +=i; } // End of for printf(“Case %d: %d\n”,j,sum); j +=1; T -=1; } // End of while } // End of main

November 25, 2017

#include <stdio.h> #include <string.h> int main() { char number; long Length,mul,pow,sum=0,number1,power; while(1) { scanf(“%s”,number); Length=strlen(number); if(Length==1 && number==48) break; else { power=Length; for(long i=0;i<Length;i++) { pow=1; for(long j=48;j<=57;j++) { if(j==number) { number1=j-48; break; }//End of if }//End of inner for for(long i1=1;i1<=power;i1++) pow=pow*2; mul=pow-1; sum=sum+number1*mul; power=power-1; }//End of outer for printf(“%d\n”,sum); }//End of els sum=0;

November 25, 2017

#include <stdio.h> int prime(int x); long sum=1,store; int main() { long Number,N,N1,prime1,prime2,a,save; scanf(“%ld”,&Number); for(long i3=1;i3<=Number;i3++) { scanf(“%ld”,&N); if(N%2==0) N1=N/2; else { int N2=N+1; N1=N2/2; } for(long i=N1;i<=N;i++) prime(i); for(int i=1;i<sum;i++) a=store; int r=1; for(int i=1;i<sum;i++) { for(int p=1;p<=5;p++) { if((a*p <= N) && (N < a*(p+1))) { save= N-p*a; prime2= a; r=r+1; } } }