解题思路:
每一轮先出比对方大1点的车,如果没有则寻找大2点的,如果还没有则只能找相等的以保证平局,相等的也没有则这一轮必输,把最差的出掉(即比对方小2点的)
注意事项:
代码写的有点繁冗,可以优化下,这方法感觉有点不靠谱但是也能AC,←__←
参考代码:
#include <stdio.h> int main() { int i,j,tmp; int n, win = 0, lose = 0; int a[30] = { 0 }; int b[30] = { 0 }; int findflag; while(scanf("%d", &n) !=EOF ) { for(i=0;i<n;i++) scanf("%d", &a[i]); for(i=0;i<n;i++) scanf("%d", &b[i]); for(i=0;i<n;i++) { findflag = 0; for(j=i;j<n;j++) { if(b[j] - a[i] == 1) { tmp = b[j]; b[j] = b[i]; b[i] = tmp; win++; findflag = 1; break; } } if(findflag == 0) { for(j=i;j<n;j++) { if(b[j] - a[i] == 2) { tmp = b[j]; b[j] = b[i]; b[i] = tmp; win++; findflag = 1; break; } } } if(findflag == 0) { for(j=i;j<n;j++) { if(b[j] == a[i]) { tmp = b[j]; b[j] = b[i]; b[i] = tmp; findflag = 1; break; } } } if(findflag == 0) { for(j=i;j<n;j++) { if(a[i] - b[j] == 2) { tmp = b[j]; b[j] = b[i]; b[i] = tmp; lose++; findflag = 1; break; } } } if(findflag == 0) lose++; } printf("%d\n", win*50-lose*50); win=0; lose=0; } return 0; }
0.0分
0 人评分