原题地址
水题, 纯模拟.
代码实现如下:
- #include <bits/stdc++.h>
- using namespace std;
- #define rep(i, a, b) for (register int i = a; i <= b; i++)
- #define per(i, a, b) for (register int i = a; i>= b; i--)
- const int maxn = 15;
- int ans = 0;
- int num[maxn], mat[maxn], poker[maxn][maxn];
- int judge(char ch) {
- if (ch>= '0' && ch <= '9') return 0;
- if (ch == 'A' || ch == 'J' || ch == 'Q' || ch == 'K') return 0;
- return 1;
- }
- int get_char(char ch) {
- if (ch == 'A') return 1;
- if (ch == '0') return 10;
- if (ch == 'J') return 11;
- if (ch == 'Q') return 12;
- if (ch == 'K') return 13;
- return ch - '0';
- }
- void write(int x) {
- if (x <0) {
- putchar('-');
- x = -x;
- }
- if (x> 9) write(x / 10);
- putchar(x % 10 + '0');
- }
- int main() {
- rep(i, 1, 13)
- per(j, 4, 1) {
- char ch = getchar();
- if (judge(ch)) ch = getchar();
- poker[i][j] = get_char(ch);
- }
- num[13] = 4;
- while (num[13]) {
- int now = poker[13][num[13]];
- num[13]--;
- while (now != 13) {
- mat[now]++;
- num[now]++;
- now = poker[now][num[now]];
- }
- }
- rep(i, 1, 12) ans += (mat[i] == 4);
- write(ans);
- return 0;
- }
- View Code
来源: http://www.bubuko.com/infodetail-3044457.html