第十屆山東理工大學ACM網路程式設計擂臺賽 熱身賽 搶救版題解
阿新 • • 發佈:2018-12-22
A:
#include<stdio.h>
int main()
{
printf("BCBAD\n");
return 0;
}
B:
#include<iostream> #include<algorithm> #include<stack> #include<queue> #include<stdio.h> #include<cmath> #include<cstring> using namespace std; # define ll long long # define maxn 1000000+1000 # define inf 0x3f3f3f3f int ans[maxn]; int main() { memset(ans,0,sizeof(ans)); int n; scanf("%d",&n); for(int i=1; i<=n; i++) { scanf("%d",&ans[i]); ans[i]+=ans[i-1]; } int t1,t2; while(~scanf("%d %d",&t1,&t2)&&(t1+t2)) { if(t1!=0) printf("%d\n",ans[t2]-ans[t1-1]); else printf("%d\n",ans[t2]); } return 0; }
C:
#include <stdio.h> int main() { int n, i, j; while(scanf("%d", &n) != EOF) { for(i = 1; i <= n / 2 + 1; i++) { for(j = 1; j <= n - (i - 1) * 2; j++)printf(" "); if(i == 1) { for(j = 1; j <= n; j++)printf("*"); for(j = 1; j <= n; j++)printf(" "); for(j = 1; j <= n; j++)printf("*"); } else { for(j = 1; j <= n * 3 + (i - 1) * 4; j++)printf("*"); } printf("\n"); } for(i = n / 2 + 2; i <= n; i++) { for(j = 1; j <= n * 3 + (n / 2) * 4; j++)printf("*"); printf("\n"); } for(i = 1; i <= n; i++) { for(j = 1; j <= i * 2; j++)printf(" "); for(j = 1; j <= n * 3 + (n / 2) * 4 - 4 * i; j++)printf("*"); printf("\n"); } } return 0; }
D:
#include <stdio.h> #include <stdlib.h> //#include<bits/stdc++.h> int main() { int n,x,y,i,MAXx,MAXy,MINx,MINy,ans; scanf("%d",&n); MAXx = -1,MAXy = -1; MINx = 100000 ,MINy = 100000 ; for(i=1;i<=n;i++) { scanf("%d%d",&x,&y); if(x > MAXx) MAXx = x; if(x < MINx) MINx = x; if(y > MAXy) MAXy = y; if(y < MINy) MINy = y; } if(MAXx - MINx > MAXy - MINy) ans = (MAXx-MINx) * (MAXx - MINx); else ans = (MAXy - MINy) * (MAXy - MINy); printf("%d\n",ans); return 0; }
E:
#include <stdio.h>
int main()
{
int n,m;
while(~scanf("%d %d",&n,&m))
{
if(n+m>=4)
{
if(n==0&&m==4)printf("ldq is the winner!\n");
else printf("Xh is the winner!\n");
}
else if(n==0&&m==3)printf("Xh is the winner!\n");
else if(n==1&&m==1)printf("Xh is the winner!\n");
else printf("ldq is the winner!\n");
}
return 0;
}