记录编号 99808 评测结果 AAAAAAAAAAAA
题目名称 黑杰克 最终得分 100
用户昵称 GravatarOI永别 是否通过 通过
代码语言 C++ 运行时间 0.003 s
提交时间 2014-05-01 11:35:06 内存使用 0.31 MiB
显示代码纯文本
#include<cstdio>
#include<iostream>
using namespace std;
int n, num[20];
char a,b,c;


int charToInt(char x) {
	int ret = 0;
	if (x>='2' && x<='9') ret = x - '0';
	else if (x == 'J' || x == 'Q' || x == 'K' || x == 'T') ret = 10;
	else ret = 11;
	return ret;
}

int main()
{
	freopen("jack0.in","r",stdin);
	freopen("jack0.out","w",stdout);
	cin>>n;
	for (int i=1; i<10; i++) num[i] = n * 4;
	num[10] = n * 16;
	cin>>a>>b>>c;
	int ra = charToInt(a), rb = charToInt(b), rc = charToInt(c);
	int myScore = rb + rc;
	if (myScore == 22) myScore = 12;
	if (ra == 11) num[1]--; else num[ra]--; 
	if (rb == 11) num[1]--; else num[rb]--; 
	if (rc == 11) num[1]--; else num[rc]--;
	double sum = 0, win = 0;
	for (int i=1; i<=10; i++) {
		int hisScore = ra;
		if (i == 1) hisScore += 11; else hisScore += i;
		if (hisScore == 22) hisScore = 12;
		if (myScore > hisScore) win+=num[i];
		sum+=num[i];
	}
	double ans = win / sum;
	printf("%.5lf\n",ans);
}