⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1055.cpp

📁 这是哈尔滨工业大学acmOJ的源代码
💻 CPP
字号:
/*  This Code is Submitted by wywcgs for Problem 1055 on 2006-02-12 at 02:46:11 */ 
#include <cstdio>

const int C_MAX = 128;
const int N_MAX = 1024;

int main()
{
	double remain[N_MAX][C_MAX];
	int i, j, c, n, m;

	while(scanf("%d %d %d", &c, &n, &m) == 3 && c != 0) {
		if(m > c || m > n || (m+n)%2 != 0) { printf("0.000\n"); continue; }
		if(n > 1000) n = 1000 + (n&1);
		remain[0][0] = 1;
		for(i = 1; i <= n; i++)
			for(j = i&1; j <= c; j += 2) {
				remain[i][j] = remain[i-1][j+1]*(j+1.0)/c;
				if(j != 0) remain[i][j] += remain[i-1][j-1]*(c-j+1.0)/c;
			}
		printf("%.3lf\n", remain[n][m]);
	}
	
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -