【CF 453A】 A. Little Pony and Expected Maximum(期望、快速幂)
2017-04-21 19:44
501 查看
A. Little Pony and Expected Maximum
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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 mdots. Twilight Sparkle is sure that when the dice is tossed, each face appears with probability
View Code
2017-04-21 19:44:52
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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 mdots. Twilight Sparkle is sure that when the dice is tossed, each face appears with probability
1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<iostream> 5 #include<algorithm> 6 #include<cmath> 7 using namespace std; 8 #define Maxn 100010 9 10 double qpow(double x,int b) 11 { 12 double ans=1; 13 while(b) 14 { 15 if(b&1) ans=ans*x; 16 x=x*x; 17 b>>=1; 18 } 19 return ans; 20 } 21 22 int main() 23 { 24 int m,n; 25 scanf("%d%d",&m,&n); 26 double ans=0; 27 for(int i=1;i<=m;i++) 28 { 29 ans+=i*(qpow(1.0*i/m,n)-qpow(1.0*(i-1)/m,n)); 30 } 31 printf("%.5lf\n",ans); 32 return 0; 33 }
View Code
2017-04-21 19:44:52
相关文章推荐
- 【CF 453A】 Little Pony and Expected Maximum (最大期望)
- Little Pony and Expected Maximum CodeForces - 453A (数学期望)
- D-- Little Pony and Expected Maximum(CF--453A
- Codeforces Round #259 (Div. 2)C. Little Pony and Expected Maximum(数学期望)
- Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum (数学期望)
- CF 453A(Little Pony and Expected Maximum-若干次掷骰,最大那次期望-推公式)
- CF 453A(Little Pony and Expected Maximum-若干次掷骰,最大那次期望-推公式)
- CodeForces 453 A.Little Pony and Expected Maximum(快速幂)
- C. Little Pony and Expected Maximum
- [Codeforces453A]Little Pony and Expected Maximum(概率期望+快速幂)
- Codeforces Round #259 (Div. 2) C. Little Pony and Expected Maximum
- C - Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum
- codeforces——Little Pony and Expected Maximum
- codeforces 453-A Little Pony and Expected Maximum
- 神奇stl- - Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 2) C Little Pony and Expected Maximum
- A. Little Pony and Expected Maximum
- codeforces C. Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 2)-C. Little Pony and Expected Maximum