大水题一道。纯模拟代码才60行。
1 #include2 using namespace std; 3 4 int pile[14][5], open[13]; 5 6 inline bool ban(char c) { 7 if(c <= '9' && c >= '0') return 0; 8 if(c == 'A' || c == 'J' || c == 'Q' || c == 'K') { 9 return 0;10 }11 return 1;12 }13 14 inline int get(char c) {15 if(c == 'A') {16 return 1;17 }18 if(c == 'J') {19 return 11;20 }21 if(c == 'Q') {22 return 12;23 }24 if(c == 'K') {25 return 13;26 }27 if(c == '0') {28 return 10;29 }30 return c - '0';31 }32 33 int main() {34 for(int i = 1; i <= 13; i++) {35 for(int j = 4; j >= 1; j--) {36 char c = getchar();37 while(ban(c)) {38 c = getchar();39 }40 pile[i][j] = get(c);41 }42 }43 pile[13][0] = 4;44 while(pile[13][0]) {45 int k = pile[13][pile[13][0]];46 pile[13][0]--;47 while(k != 13) {48 open[k]++;49 pile[k][0]++;50 k = pile[k][pile[k][0]];51 }52 }53 int ans = 0;54 for(int i = 1; i <= 12; i++) {55 ans += (open[i] == 4);56 }57 printf("%d", ans);58 return 0;59 }