Codeforces Round #259 (Div. 2) C Little Pony and Expected Maximum
2014-08-02 09:26
537 查看
用逆向思维解+容斥原理
最大为 m 个的概率为 1减去不是m最大的概率,(1 - (( m-1 )/ m ) ^ n ),则 m-1 的概率为 在 不是 m 的状态下 乘以 1减去不是m-1最大的概率
以此类推
感谢楠哥的思路
最大为 m 个的概率为 1减去不是m最大的概率,(1 - (( m-1 )/ m ) ^ n ),则 m-1 的概率为 在 不是 m 的状态下 乘以 1减去不是m-1最大的概率
以此类推
感谢楠哥的思路
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <climits> #include <complex> #include <fstream> #include <cassert> #include <cstdio> #include <bitset> #include <vector> #include <deque> #include <queue> #include <stack> #include <ctime> #include <set> #include <map> #include <cmath> #define eps 1e-9 #define INF 0x3f3f3f3f using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef complex<ld> point; typedef pair<int, int> pii; typedef pair<pii, int> piii; template<class T> inline bool read(T &n) { T x = 0, tmp = 1; char c = getchar(); while((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar(); if(c == EOF) return false; if(c == '-') c = getchar(), tmp = -1; while(c >= '0' && c <= '9') x *= 10, x += (c - '0'),c = getchar(); n = x*tmp; return true; } template <class T> inline void write(T n) { if(n < 0) { putchar('-'); n = -n; } int len = 0,data[20]; while(n) { data[len++] = n%10; n /= 10; } if(!len) data[len++] = 0; while(len--) putchar(data[len]+48); } //----------------------------------- const int MAXN=100010; int n,m; double ans=0; int main() { int n,m; read(m);read(n); for (int i=1;i<=m;i++) ans+=i*pow((double)i/(double)m,n)*(1-pow((double)(i-1)/(double)i,n)); printf("%.12lf",ans); return 0; }
相关文章推荐
- Codeforces Round #259 (Div. 1) A. Little Pony and Expected Maximum 数学公式结论找规律水题
- Codeforces Round #259 (Div. 2) C. Little Pony and Expected Maximum
- codeforces #259 DIV2 C题 Little Pony and Expected Maximum(容斥+快速幂+公式推导)
- Codeforces Round #259 (Div. 2) E. Little Pony and Summer Sun Celebration
- Codeforces Round #259 (Div. 2) A-Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift
- Codeforces Round #259 (Div. 2) A.Little Pony and Crystal Mine
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift(序列)
- Codeforces Round #259 (Div. 2)-D. Little Pony and Harmony Chest
- Codeforces Round #259 (Div. 2) B - Little Pony and Sort by Shift
- Little Pony and Expected Maximum CodeForces - 453A (数学期望)
- Codeforces Round #169 (Div. 2) D. Little Girl and Maximum XOR(贪心,中等)
- 【Codeforces Round 169 (Div 2) D】【简单数位贪心】Little Girl and Maximum XOR 区间选两数使得异或值尽可能大
- Codeforces Div. 2 #259-A. Little Pony and Crystal Mine
- Codeforces Div. 2 #259-C. Little Pony and Expected Maximum
- codeforces C. Little Pony and Expected Maximum
- Codeforces Round #129 (Div. 2) D. Little Elephant and Cards
- CF #259 div.2 C. Little Pony and Expected Maximum
- Codeforces Round #259 (Div. 1) A Little Pony and Expected Maximum
- Codeforces Round #129 (Div. 1) B. Little Elephant and Cards