资源描述:
《acm入门题(北大oj)》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、1000#includeintmain(){inta,b,c;while(scanf("%d%d",&a,&b)!=EOF){c=a+b;printf("%d",c);}}1067#include#include#includeintmain(){inta,b;while(scanf("%d%d",&a,&b)!=EOF){if(a>b){intt=a;a=b;b=t;}intk=b-a;inta0=(int)(k*(1+sqrt(5.0))/2);if(a0=
2、=a)printf("0");elseprintf("1");}}1080#include#includeinta[5][5]={5,-1,-2,-1,-3,-1,5,-3,-2,-4,-2,-3,5,-2,-2,-1,-2,-2,5,-1,-3,-4,-2,-1,0};intmain(){intca;scanf("%d",&ca);while(ca--){intn,m,i,j,max[105][105],b[105],d[105];chars[105],c[105];scanf("%d%s
3、",&n,s);scanf("%d%s",&m,c);for(i=1;i<=n;i++){if(s[i-1]=='A')b[i]=0;if(s[i-1]=='C')b[i]=1;if(s[i-1]=='G')b[i]=2;if(s[i-1]=='T')b[i]=3;}for(i=1;i<=m;i++){if(c[i-1]=='A')d[i]=0;if(c[i-1]=='C')d[i]=1;if(c[i-1]=='G')d[i]=2;if(c[i-1]=='T')d[i]=3;}max[0][0]=0;for(i=1;i<=n;i++)m
4、ax[i][0]=max[i-1][0]+a[b[i]][4];for(i=1;i<=m;i++)max[0][i]=max[0][i-1]+a[4][d[i]];for(i=1;i<=n;i++)for(j=1;j<=m;j++){max[i][j]=max[i-1][j-1]+a[b[i]][d[j]];if(max[i-1][j]+a[b[i]][4]>max[i][j])max[i][j]=max[i-1][j]+a[b[i]][4];if(max[i][j-1]+a[4][d[j]]>max[i][j])max[i][j]=m
5、ax[i][j-1]+a[4][d[j]];}printf("%d",max[n][m]);}}1013#include#include#include#include#definePI3.141592653usingnamespacestd;structpoint{doublex;doubley;}p[30005],res[30005];intcmp(pointp1,pointp2){returnp1.y6、
7、(p1.y==p2.y&&p1.x
8、2.x);}boolral(pointp1,pointp2,pointp3){if((p2.x-p1.x)*(p3.y-p1.y)<=(p2.y-p1.y)*(p3.x-p1.x))returntrue;returnfalse;}doubledis(pointp1,pointp2){returnsqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));}intmain(){intn,m;while(scanf("%d%d",&n,&m)!=EOF){inti,j;for(i=0;i9、i++)scanf("%lf%lf",&p[i].x,&p[i].y);sort(p,p+n,cmp);res[0]=p[0];res[1]=p[1];inttop=1;for(i=2;i=0;i--){while(top!=len&&ral(res[top-1],res[top],p[i]))top--;res[
10、++top]=p[i];}doublet=0;for(i=0;i