Codeforces 1191B Tokitsukaze and Mahjong
题目链接:http://codeforces.com/problemset/problem/1191/B
题意:类似于麻将,三个一样花色一样数字的,或者三个同花顺就赢了,新抽的能当任何类型,问至少几个。
思路:分类判断即可。
AC代码:
#include<bits/stdc++.h>
using namespace std;
string a, b, c;
bool check(int x, int y, int z){
if (x == (y + z) / 2 && abs(y - z) == 2) return true;
if (y == (x + z) / 2 && abs(x - z) == 2) return true;
if (z == (y + x) / 2 && abs(y - x) == 2) return true;
return false;
}//同花顺检测
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0);
cin >> a >> b >> c;
int x = a[0] - '0';
int y = b[0] - '0';
int z = c[0] - '0';
if (a[1] == b[1] && b[1] == c[1])
if ((x == y && y == z) || check(x, y, z)) return cout << 0, 0;
else if (abs(x - y) <= 2 || abs(z - y) <= 2 || abs(x - z) <= 2) cout << 1 << endl;
else cout << 2 << endl;
else if (a[1] == b[1])
if (x == y || abs(x - y) <= 2) cout << 1 << endl;
else cout << 2 << endl;
else if (b[1] == c[1])
if (z == y || abs(z - y) <= 2) cout << 1 << endl;
else cout << 2 << endl;
else if (a[1] == c[1])
if (x == z || abs(x - z) <= 2) cout << 1 << endl;
else cout << 2 << endl;
else cout << 2 << endl;
return 0;
}