0w1

CFR 453 1A. Little Pony and Expected Maximum ( Math, Expectancy )

http://codeforces.com/problemset/status
The number of situations such that the face x is of the maximum, is ( x^n - ( x - 1 )^n ).
So the expectancy we are looking for can be calculated as
{ \displaystyle
E = \sum_{i=1}^{m} i * ( i^n - ( i - 1 )^n ) / m^n
}
However, simply implementing this, you will find it overflow. We need to change the form a little so,
{ \displaystyle
E = \sum_{i=1}^{m} i * (  ( i / m )^n - ( ( i - 1 ) / m )^n )
}
Curious as I was, I looked up the time complexity of pow() function. It somewhat surprised me that in most cases, the operation will be finished in constant time.

void solve(){
    scanf( "%d%d", &M, &N );
    double ans = 0;
    for( int i = 1; i <= M; ++i )
        ans += ( pow( 1.0 * i / M, N ) - pow( ( 1.0 * i - 1 ) / M, N ) ) * i;
    printf( "%.6lf\n", ans );
}