西北工业大学-c语言-POJ-题目及-答案_第三季

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

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

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

资源描述

T021#includestdio.h#includestdlib.hintmain(){intA[18],x,y=0,n,i,j;scanf(%d,&n);for(i=0;in;i++)scanf(%d,&A[i]);for(i=0;in;i++){x=1;for(j=i;jn;j++){x=x*A[j];if(xy)y=x;}}if(y0)printf(%d\n,y);elseprintf(-1\n);return0;}T022#includestdio.h#includestdlib.hintmain(){inti,j,t,x,y;scanf(%d,&t);if(t==1)x=0,y=3;if(t=2){x=0;y=3;}for(i=2;i=t;i++){j=y;y=x*3+y*2;x=j;}printf(%d%d\n,x,y);return0;}T023#includestdio.h#includestdlib.hintmain(){intk,x,y;scanf(%d,&k);for(x=k*(k+1);x0;x--)for(y=1;y=x;y++)if(k*(x+y)==x*y)printf(1/%d=1/%d+1/%d\n,k,x,y);return0;}T024T025#includestdio.h#includestdlib.h#includemath.hintmain(){intm,n,i;doublex,s=0;scanf(%d%d,&n,&m);for(i=n;i=m;i++){x=pow(i,2.0);s=s+1/x;}printf(%.5lf\n,s);return0;}T026#includestdio.h#includestdlib.h#includemath.hintmain(){longa=1,b,k;ints,x,n,m=0;scanf(%d,&n);while(1){a++;s=0;for(b=a*100-99;b=a*100-1;b+=2){x=0;for(k=3;k=sqrt(b);k+=2)if(b%k==0){x=1;break;}if(x==0)break;s=s+x;}if(s==50){m++;if(n==m){printf(%ld%ld\n,a*100-100,a*100-1);break;}}}return0;}T027#includestdio.h#includestdlib.h#includemath.hintmain(){intn;intf(int);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;}T028#includestdio.h#includestdlib.h#includemath.hintmain(){intm,n,g=0,s=0,i,j,x,x1,x2;scanf(%d%d,&m,&n);x1=(int)(pow(10.0,n)/10);x2=(int)(pow(10.0,n)-1);for(i=x1;i=x2;i++){j=i;do{x=j%10;if(x==m){if(i%m!=0)g++,s=s+i;break;}elsej=j/10;}while(j!=0);}printf(%d%d\n,g,s);return0;}T029#includestdio.h#includestdlib.hintmain(){inti=7,x,y,n;scanf(%d,&n);while(i=n){if(i%7==0){printf(%d,i);i++;continue;}else{x=i;while(x=7){y=x-x/10*10;if(y==7){printf(%d,i);break;}x=x/10;}i++;}}printf(\n);return0;}T030#includestdio.h#includestdlib.hintmain(){intn=0,i,j,s1,x;scanf(%d,&x);for(i=1;i=x;i++){j=i;do{s1=j%10;if(s1==1)n++;j=j/10;}while(j!=0);}printf(%d\n,n);return0;}

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

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

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

×
保存成功