[题解]ZOJ Monthly, February 2011 » ZOJ3468

ZOJ3468
ZOJ3468.cpp


#include <cstdio>
#include <numeric>

using namespace std;

long long p[10][100];
long long s[10][100];

int main() {
	int a, b;
	long long ans;

	p[0][0] = 1;
	for (int i = 1; i < 10; ++i) {
		for (int j = 0; j < 90; ++j) {
			for (int k = 1; k <= 6; ++k) {
				p[i][j + k] += p[i - 1][j];
			}
		}
	}
	for (int i = 0; i < 10; ++i) {
		partial_sum(p[i], p[i] + 90, s[i] + 1);
	}

	while (scanf("%d%d", &a, &b) != EOF) {
		ans = 0;
		if (a > 1) {
			for (int i = 0; i < 90; ++i) {
				ans += p[a][i] * s[b][i];
			}
		}
		printf("%.40lf\n", (double)ans / s[a][90] / s[b][90]);
	}

	return 0;
}

//Run ID 	Submit Time 	Judge Status 	Problem ID 	Language 	Run Time(ms) 	Run Memory(KB) 	User Name 	Admin
//703 	2011-02-08 17:46:00 	Accepted 	B 	C++ 	0 	196 	watashi@ArcOfDream 	Source
4 Responses to “ZOJ3468”
  1. jing says:

    为什么shi哥肉这么多求长肉秘方o(╯□╰)o

  2. jing says:

    不知道这题中所说的“骰子分成两堆有什么用”

  3.  
Leave a Reply