qscqesze
Published on 2017-09-02 11:31 in 暂未分类 with qscqesze

# A. Little Pony and Expected Maximum

Time Limit: 1 Sec  Memory Limit: 256 MB

## 题目连接

http://codeforces.com/contest/453/problem/A

## Description

Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.

The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, and so on, the m-th face contains m dots. Twilight Sparkle is sure that when the dice is tossed, each face appears with probability . Also she knows that each toss is independent from others. Help her to calculate the expected maximum number of dots she could get after tossing the dice n times.

## Input

A single line contains two integers m and n (1 ≤ m, n ≤ 105).

## Output

Output a single real number corresponding to the expected maximum. The answer will be considered correct if its relative or absolute error doesn't exceed 10  - 4.

6 1

3.500000000000

## HINT

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff;   //无限大
const int inf=0x3f3f3f3f;
/*
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int buf[10];
inline void write(int i) {
int p = 0;if(i == 0) p++;
else while(i) {buf[p++] = i % 10;i /= 10;}
for(int j = p-1; j >=0; j--) putchar('0' + buf[j]);
printf("\n");
}
*/
//**************************************************************************************

int main()
{
int m,n;
cin>>m>>n;
double pre=0;
double ans=0;
for(int i=1;i<=m;i++)
{
double now=pow((double(i)/double(m)),double(n));
//cout<<now<<endl;
ans+=(now-pre)*i;
pre=now;
}
printf("%.10f\n",ans);
}

posted @ 2015-04-09 19:17  qscqesze  阅读(193)  评论(0编辑  收藏