codeforces round265 div1 D World of Darkraft - 2 - ShinriiTin's Blog - 博主是sb
library
codechef Dynamic GCD

codeforces round265 div1 D World of Darkraft - 2

ShinriiTin posted @ 2015年6月12日 16:33 in 未分类 with tags dp 概率与期望 , 517 阅读

详见zhj的15年集训队论文

Portal

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;++i)
typedef long double ld; 

const int MAXN=1000; 

int n,k,cur;

ld dp[2][MAXN];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=n;i;--i){
		cur^=1;
		int B=701;
		rep(j,1,B){
			dp[cur][j]=(dp[cur^1][j]+(1.+j)/2)*j;
			dp[cur][j]+=(dp[cur^1][j+1]+j);
			dp[cur][j]/=j+1;
			dp[cur][j]+=dp[cur^1][j]*(k-1);
			dp[cur][j]/=k;
		}
	}
	ld ans=dp[cur][1]*k;
	printf("%.20f\n",(double)ans);
	return 0;
}
Avatar_small
Brooke De 说:
2018年11月28日 16:00

The code of the writer is ensured for the production of the quality of the content. The ascertainment of the term and writers per hour discount code is highlighted for the acute terms for the humans. The challenge is inquired for the formation of the better slots for the humans in life.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter