ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1009. K-based Numbers

Is this looks like correct?
Posted by PVD 27 Sep 2013 01:36
i have tested it, and it look like working, can you say me is this look like correct, or can you advise me how to fix it?)

#include <iostream>

using namespace std;

int main()
{
    unsigned __int64 n, b, i, r, sum = 0;
    cin>>n>>b;
    for (i = 2; i <= n - 1; i++)
    {
        r = (n - 1) / i + (n - 1) % i;
        sum += r * pow(double(b - 1), double(n - i));
    }
    cout<<unsigned __int64(pow(double(b), double(n)) - pow(double(b), double(n - 1)) - sum)<<endl;
    //system("pause");
}