标签:logs span limit sum ace scan tmp number mic
题目1 : Dice Possibility
描述
What is possibility of rolling N dice and the sum of the numbers equals to M?输入
Two integers N and M. (1 ≤ N ≤ 100, 1 ≤ M ≤ 600)输出
Output the possibility in percentage with 2 decimal places.#include<stdio.h> #include<string.h> #include<stdlib.h> double dp[105][605]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif int n, m; scanf("%d%d", &n, &m); memset(dp, 0, sizeof(dp)); for (int i = 1; i <= 6; i++) { dp[1][i] = 1.0 / 6.0; } for (int i = 2; i <= n; i++) { for (int j = i; j <= 6 * i; j++) { double tmp = 0; for (int k = 1; k <= 6; k++) { tmp += dp[i - 1][j - k]; } tmp /= 6.0; dp[i][j] = tmp; } } printf("%.2lf\n", dp[n][m] * 100); return 0; }
标签:logs span limit sum ace scan tmp number mic
原文地址:http://www.cnblogs.com/dramstadt/p/7753336.html