题目:http://icpc.njust.edu.cn/Problem/CF/104A/
AC代码(C++):
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <string.h>
#include <math.h>
#define INF 0x3f3f3f3f
#define eps 1e-8
typedef unsigned long long ull;
typedef long long ll;
typedef __int64 I64d;
using namespace std;
int n;
int card[51] = { 2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,-1,-1,-1,-1 };
int main() {
while (cin >> n) {
if (n <= 10) {
cout << 0 << endl;
continue;
}
int ans = 0;
for (int i = 0; i < 51; i++) {
if (card[i] != -1 && card[i] + 10 == n)ans++;
else if (card[i] == -1 && (11 == n || 21 == n))ans++;
}
cout << ans << endl;
}
//system("pause");
}
总结: 模拟题, 硬干.