Notes2
2015-08-12 22:16
435 查看
UVa 340
#include <stdio.h> #define MAX 1020 int main() { int n, i, cas = 1; int code[MAX], guess[MAX], hash1[20], hash2[20]; while(1) { scanf("%d", &n); if(!n) break; for(i = 0; i < n; i++) scanf("%d", &code[i]); printf("Game %d:\n", cas++); while(1) { for(i = 0; i < n; i++) scanf("%d", &guess[i]); if(guess[0] == 0) break; int strong = 0, weak = 0; memset(hash1, 0, sizeof(hash1)); memset(hash2, 0, sizeof(hash2)); for(i = 0; i < n; i++) { if(code[i] == guess[i]) strong++; else { hash1[code[i]]++; hash2[guess[i]]++; } } for(i = 1; i < 10; i++) weak += (hash1[i] < hash2[i])? hash1[i] : hash2[i]; printf(" (%d,%d)\n", strong, weak); } } return 0; }
相关文章推荐
- dom4j对xml解
- 并发服务器设计
- [UVA 12589]Learning Vector[DP]
- Interesting Integers(CF---BAPC 14 + hnoj11589)扩展欧几里得
- 设计模式之观察者模式
- 史上最全的CSS hack方式一览
- B Black Square----(2015 summer training #5)
- 字符串截取
- 条形码设计
- 我在Python和Ruby之间的选择
- struts.objectFactory和struts.objectFactory.spring.autoWire
- MacRitchie Reservoir hiking
- Xcode 6 正式版如何创建一个Empty Application
- Linux 常用函数
- linux中C语言获取高精度时钟gettimeofday函数
- CodeForces 569B
- Web前端面试中遇到的问题
- [Vijos]P1282 佳佳的魔法照片
- JavaScript 编程
- 【Hadoop系列第十章】(二)数据分析系统Pig