UVA-340 Master-Mind Hints (猜数字)
2015-12-21 06:30
357 查看
分析:猜数字游戏,水题
#include<cstdio>#include<algorithm>#include<map>using namespace std;const int N = 1005;int a, b, c, d;int main(){int n, cas = 0;while (scanf ("%d", &n), n){map<int, int> aa;printf ("Game %d:\n", ++cas);for (int i = 0; i < n; ++i){scanf ("%d", &a[i]);++aa[a[i]];}while (1){map<int, int> bb;for (int i = c = d = 0; i < n; ++i){scanf ("%d", &b[i]);++bb[b[i]];if (a[i] == b[i]) c++;}if (!b[0]) break;for (int i = 1; i <= 9; ++i)d += min (aa[i], bb[i]);printf (" (%d,%d)\n", c, d - c);}}return 0;}
相关文章推荐
- Data URI 应用场景小结
- [leetcode] 22. Generate Parentheses 解题报告
- urllib.urlretrieve()
- Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04
- *Reverse Linked List II
- LeetCode - Remove Duplicates from Sorted Array
- C标准库没提供的助手函数:字符串替换
- LeetCode - Reverse Nodes in k-Group
- Leetcode: Shortest Word Distance II
- Android RecyclerView使用详解四
- *Insertion Sort List
- python对文件及文件夹的一些操作
- 二分查找(折半查找)
- 文章标题
- 312. Burst Balloons
- 处理字符串的一些C函数
- isalpha判断字母函数的使用
- PHP(三)变量、常量
- Unity C#脚本热更
- [hdu4285 circuits] 插头dp