Codeforces not showing correct output.

I am doing this question on codeforces.

It shows wrong answer on test case 12, it says correct answer is 674074074074073.
but on my terminal it shows 674074074074073 answer only.

What could be the reason ?

Here is my code.

typedef long long ll;
using namespace std;

int count(ll m)
    int cnt = 0;

        m /= 10;
return cnt;

int main()

    ll w,m,k;

    cin >> w >> m >> k;

    ll ans = 0;
    int dig = count(m);
        ll num = pow(10,dig);
        if(w >= ((num-m)*dig*k))
            ans += (num-m);
            w = w-((num-m)*dig*k);
            m = num;
            ans += (w/(k*dig));
    cout << ans << endl;
return 0;

alt text

No, your output is coming 674074074074072 not 674074074074073 . Please check the screenshot of your submission on codeforces.

In your code, there is overflow problem, use unsigned long long instead of long long . Also, do not use inbuilt pow function for calculating pow(10,dig), make your own code for calculating it. Since, sometimes the pow function gives wrong answer in c/c++. e.g. in my codeblocks, it is showing pow(10,2)=99. So, please write your own code for it. Best of luck!!


Yes, pow function is the reason, thanks a lot… :slight_smile: