http://acm.hust.edu.cn/vjudge/contest/view.action?cid=31675#problem/M
// File Name: uvala2991.cpp
// Author: bo_jwolf
// Created Time: 2013年09月24日 星期二 15:36:44
#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
int main()
{
double m , p , a , b , sum , temp ;
int l , r ;
while( scanf( "%lf%lf%lf%lf" , &m , &p , &a , &b ) != EOF )
{
sum = l = r = 0 ;
temp = a * b ;
for( int i = 0 ; i < m - 1 ; ++i )
{
if( temp < a )
{
l++ ;
temp++ ;
}
else
{
r++ ;
temp -= a ;
}
}
sum += l / ( pow( sqrt( a ) , p ) ) ;
sum += r * ( pow( sqrt( a ) , p ) ) ;
sum += pow( temp / sqrt( a ) , p ) ;
printf( "%d\n" , (int ) ( sum + 0.5 ) );
}
return 0;
}