赞
踩
输入:
10,2,5,6,13,11,11,4,10,8,12,5,4,1,8,1,7,12,4,13,6,9,9,9,5,7
6,3,13,8,2,3,7,3,2,2,12,11,10,6,10,1,1,12,3,5,7,11,13,4,8,9
输出:
Byte
说明:最终小Byte获得31张牌,小Dance获得19张牌,剩下两张点数为6,9的牌。
- void main()
- {
- B = D = 0;
- vector<int> b = { 10,2,5,6,13,11,11,4,10,8,12,5,4,1,8,1,7,12,4,13,6,9,9,9,5,7 };
- vector<int> d = { 6,3,13,8,2,3,7,3,2,2,12,11,10,6,10,1,1,12,3,5,7,11,13,4,8,9 };
- vector<int> a(60, 0);
- int c = 0;
- for (int i = 0; i<26; i++) {
- a[c++] = b[i];
- for (int j = c - 2; j >= 0; j--) {
- if (a[j] == b[i]) {
- B += c - j;
- c = j;
- }
- }
- a[c++] = d[i];
- for (int j = c - 1; j >= 0; j--) {
- if (a[j] == d[i]) {
- D += c - j;
- c = j;
- }
- }
- }
- if (B == D) printf("Draw\n");
- else if (B > D) printf("Byte\n");
- else printf("Dance\n");
- }

总结:添加到一个新的数组,添加时要进行从后往前的查找,第一个重复的数字就是要赢得的牌序列,然后从这个位置重新覆盖新的数组序列就可以(这个操作就相当于对牌进行了删除)。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。