|
|
вернуться в форумWHY MY ALGORITM IS WRONG? #include<iostream.h> int power(int a, int b) { if(b==0) return 1; if(b%2==0) return power(a, b/2) * power(a, b/2); if(b%2!=0) return power(a, b/2) * power(a, b/2) * a; } int main() { int n, k; cin>>n>>k; int a, b; a=power(k, n-1) * (k-1); b=power(2, n-1); cout<<a-b+n<<endl; return 0; } I think that the answer of this problem is (k-1)*k^(n-1)-2^(n-1)+n why it is wrong i don't understand. Re: WHY MY ALGORITM IS WRONG? Послано bzaz 2 апр 2009 20:18 Because it is not working!!!!!!!!!!!!!!!!!!!!! Re: WHY MY ALGORITM IS WRONG? yes it doesn't! =) Re: WHY MY ALGORITM IS WRONG? yes it doesn't! =) Don't use alien wrong solution! |
|
|