uva 340
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=276
今天開始準備去uva做題,推薦一本書《》算法競賽入門經典》這本書會對uva上部分題目進行講解,很不錯。 今天做了uva 340,后續(xù)會繼續(xù)堅持刷題的。
/* THE PROGRAM IS MADE BY SH */ /*---------------------------------------------------------------------------* https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=276* 猜數字游戲的提示 * Date : 2015/6/8 ----------------------------------------------------------------------------*/ #include<stdio.h> #include <cstdio> #include <cstdlib> #define maxn 1010 int main() {int n,kase = 0;int a[maxn],b[maxn];while(scanf("%d",&n) == 1 && n){printf("Game %d:\n",++kase);for(int i = 0; i < n; ++i) scanf("%d",&a[i]);for(;;){int A = 0, B = 0;for(int i = 0; i < n; ++i){scanf("%d",&b[i]);if(a[i] == b[i]) A++;}if(b[0] == 0) break;for(int d = 1; d <= 9; ++d){int c1 = 0,c2 = 0;for(int i = 0; i < n; ++i){if(a[i] == d) c1++;if(b[i] == d) c2++;}if(c1 < c2) B += c1; else B += c2;}printf(" (%d,%d)\n",A,B-A);} }system("PAUSE");return 0; }總結
- 上一篇: 新版个人所得税计算python_个税起征
- 下一篇: 使用lterator遍历set、list