NOJ100题+解答

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#includestdio.hintmain(){inta,b,sum;scanf(%d%d,&a,&b);sum=a+b;printf(%d\n,sum);return0;}#includestdio.h#definePI3.1415926intmain(){doubler,h,l,s,sq,vq,vz;scanf(%lf%lf,&r,&h);l=2*PI*r;s=PI*r*r;sq=4*PI*r*r;vq=PI*r*r*r*4/3;vz=PI*r*r*h;printf(%.2lf\n%.2lf\n%.2lf\n%.2lf\n%.2lf\n,l,s,sq,vq,vz);return0;}#includestdio.hintmain(){doublema,eng,c,sum,ave;scanf(%lf%lf%lf,&ma,&eng,&c);sum=ma+eng+c;ave=sum/3;printf(%lf\n%lf\n,sum,ave);return0;}#includestdio.hintmain(){inta,b,c,m;scanf(%d%d%d,&a,&b,&c);if(ab)m=a;elsem=b;if(mc)m=c;printf(%d,m);return0;}#includestdio.hintmain(){intn;scanf(%d,&n);if((1000n10000)&&(n/1000==n%10)&&(n/100%10==n/10%10))printf(yes\n);elseif((100n=1000)&&(n/100==n%10))printf(yes\n);elseif((10n=100)&&(n/10==n%10))printf(yes\n);elseif(0n=10)printf(yes\n);elseprintf(no\n);return0;}#includestdio.hintmain(){doublel,bon;scanf(%lf,&l);if(l=10)bon=l*0.1;elseif(l20)bon=1+(l-10)*0.075;elseif(l40)bon=1.75+(l-20)*0.05;elseif(l60)bon=2.75+(l-40)*0.03;elseif(l100)bon=3.35+(l-60)*0.015;elsebon=3.95+(l-100)*0.01;printf(%lf\n,bon);return0;}#includestdio.hintmain(){doubled,m;scanf(%lf,&d);if(d=2)m=7;elseif(d=15){if(d-2==(int)(d-2))m=7+(d-2)*1.5;elsem=7+((int)(d-2)+1)*1.5;}elseif(d-15==(int)(d-15))m=26.5+(d-15)*2.1;elsem=26.5+((int)(d-15)+1)*2.1;printf(%lf\n,m);return0;}#includestdio.hintmain(){inty,m,d,Days,sum;scanf(%d-%d-%d,&y,&m,&d);if((y%4==0&&y%100!=0)||(y%400==0))Days=29;elseDays=28;switch(m){case1:sum=d;break;case2:sum=31+d;break;case3:sum=31+Days+d;break;case4:sum=62+Days+d;break;case5:sum=92+Days+d;break;case6:sum=123+Days+d;break;case7:sum=153+Days+d;break;case8:sum=184+Days+d;break;case9:sum=215+Days+d;break;case10:sum=245+Days+d;break;case11:sum=276+Days+d;break;case12:sum=307+Days+d;break;}printf(%d\n,sum);return0;}#includestdio.hintmain(){inti;scanf(%d,&i);if(i=90)printf(A\n);elseif(i=80)printf(B\n);elseif(i=70)printf(C\n);elseif(i=60)printf(D\n);elseprintf(E\n);return0;}#includestdio.hintmain(){doublex,y;scanf(%lf,%lf,&x,&y);if((x-2)*(x-2)+(y-2)*(y-2)=1)printf(10);elseif((x-2)*(x-2)+(y+2)*(y+2)=1)printf(10);elseif((x+2)*(x+2)+(y-2)*(y-2)=1)printf(10);elseif((x+2)*(x+2)+(y+2)*(y+2)=1)printf(10);elseprintf(0);return0;}#includestdio.hintmain(){doublel,x,r;scanf(%lf%lf,&l,&r);while((2*l*l*l-4*l*l+3*l-6)!=0&&(2*r*r*r-4*r*r+3*r-6)!=0){x=(l+r)/2;if((2*l*l*l-4*l*l+3*l-6)*(2*x*x*x-4*x*x+3*x-6)=0)r=x;elsel=x;}if(2*l*l*l-4*l*l+3*l-6==0)printf(%.2lf,l);elseprintf(%.2lf,r);return0;}#includestdio.h#includemath.hintmain(){inti=800,t=2,cnt=0,sum=0;doublee=-1;while(i=500){while(t=i-1){if(i%t==0)break;t++;}if(t==i)e=pow(-1,cnt),sum=sum+e*i,cnt++;i--;t=2;}printf(%d%d,cnt,sum);return0;}#includestdio.h#includemath.hintmain(){inta=1;doubleb=1,pi=0,c=1;while(fabs(c)=1e-6)pi=pi+c,b=b+2,a=-a,c=a/b;pi=pi*4;printf(%lf\n,pi);return0;}#includestdio.hintmain(){inta1=1,a2=1,n=2,sum=2,t;while(sum=100){t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n++;}printf(%d\n,n-1);while(sum=1000){t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n++;}printf(%d\n,n-1);while(sum=10000){t=a1;a1=a2;a2=t+2*a2;sum=sum+a2;n++;}printf(%d\n,n-1);}#includestdio.hintmain(){intx,a,s,n=1;scanf(%d%d,&x,&a);s=x;if(a!=0){for(;na;n++){s=s*x;if(s=1000)s=s/100%10*100+s/10%10*10+s%10;}}printf(%d\n,s);return0;}#includestdio.hintmain(){intm,n,s;scanf(%d,&n);s=n*n*n;printf(%d*%d*%d=%d=,n,n,n,s);for(m=1;s!=n*m;m++);if(n%2==1){for(s=-n/2;sn/2;s++)printf(%d+,m+2*s);printf(%d,m+n/2*2);}else{for(s=-n/2;sn/2-1;s++)printf(%d+,m+s*2+1);printf(%d,m+(n/2-1)*2+1);}return0;}#includestdio.hintmain(){chara,b,c,x,y,z;a='A',b='B',c='C',x='X',y='Y',z='Z';printf(%c=%c\n,a,z);printf(%c=%c\n,b,x);printf(%c=%c\n,c,y);return0;}#includestdio.hintmain(){inta,b,t;scanf(%d%d,&a,&b);if(ab)t=a,a=b,b=t;for(;ab;a++){for(t=2;ta;t++)if(a%t==0)break;if(t==a)printf(%d,a);}return0;}#includestdio.hintmain(){intn=1;doublea1=1,a2=2,a3,sum=2;while(n=19){a3=a1+a2;sum=sum+a3/a2;a1=a2;a2=a3;n++;}printf(%lf\n,sum);return0;}#includestdio.h#includemath.hintmain(){doublea;intn=0;scanf(%lf,&a);a=fabs(a);if(a=1)printf(0\n);else{while(a1){a=a/10;n++;}printf(%d\n,n);}return0;}#includestdio.hintmain(){inta=1,b=0,t,m,n=0;scanf(%d,&t);while(nt){m=b;b=3*a+2*b;a=m;n++;}printf(%d%d,a,b);return0;}#includestdio.h#includemath.hintmain(){intn;intf(intn);scanf(%d,&n);printf(%d\n,f(n));}intf(intn){inta;if(n==1||n==2)a=0;elseif(n==3)a=1;elseif(n==4)a=3;elsea=f(n-1)*2+pow(2,n-4)-f(n-4);returna;}#includestdio.hintmain(){intn,x=1234,y=1,a,b,c,d,e,f,g,h,i,j;scanf(%d,&n);for(;x49383&&y98765;x++){y=x*n;a=x/10000%10;b=x/1000%10;c=x/100%10;d=x/10%10;e=x%10;f=y/10000%10;g=y/1000%10;h=y/100%10;i=y/10%10;j=y%10;if(a==b||a==c||a==d||a==e||a==f||a==g||a==h||a==i||a==j)continue;if(b==c||b==d||b==e||b==f||b==g||b==h||b==i||b==j)continue;if(c==d||c==e||c==f||c==g||c==h||c==i||c==j)continue;if(d==e||d==f||d==g||d==h||d==i||d==j)continue;if(e==f||e==g||e==h||e==i||e==j)continue;if(f==g||f==h||f==i||f==j)continue;if(g==h||g==i||g==j)continue;if(h==i||h==j)continue;if(i==j)continue;

1 / 113
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功