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;
while(m!=0)
{
cnt++;
m /= 10;
}
return cnt;
}
int main()
{
ll w,m,k;
cin >> w >> m >> k;
ll ans = 0;
int dig = count(m);
while(1)
{
ll num = pow(10,dig);
if(w >= ((num-m)*dig*k))
{
ans += (num-m);
w = w-((num-m)*dig*k);
m = num;
}
else
{
ans += (w/(k*dig));
break;
}
dig++;
}
cout << ans << endl;
return 0;
}