资源描述:
《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+s
2、qrt(5.0))/2);if(a0==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
3、],d[105];chars[105],c[105];scanf("%d%s",&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
4、]=2;if(c[i-1]=='T')d[i]=3;}max[0][0]=0;for(i=1;i<=n;i++)max[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[
5、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]=max[i][j-1]+a[4][d[j]];}printf("%d",max[n][m]);}}1013#include#include#include#include#definePI3.141592653usingnamespacestd;structpoint{do
6、ublex;doubley;}p[30005],res[30005];intcmp(pointp1,pointp2){returnp1.y7、
8、(p1.y==p2.y&&p1.x9、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;i10、[i]))top--;res[++top]=p[i];}intlen=top;res[++top]=p[n-2];for(i=n-3;i>=0;i--){while(top!=len&&ral(res[top-1],res[top],p[i]))top--;res[++top]=p[i];}doublet=0;for(i=0;i