Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.6 kB
0
Indexable
Never
#include<bits/stdc++.h>
#include<algorithm>

#define spd_emergency ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define ff first
#define ss second
#define mloop(i) for(auto i=m.begin();i!=m.end();i++)
#define pb push_back
#define pll pair<ll,ll> 
#define pii pair<int,int> 
#define mod1 1125899906842597LL

using namespace std;
vector<bool> prime(200002,true);
void seive(ll mx)
{
	prime[0]=prime[1]=false;
	for(ll i=2;i*i<=mx;i++)
	{
		if(prime[i])
		{
			for(ll j=i*i;j<=mx;j+=i)
			{
				prime[j]=false;
			}
		}
	}
}

const ll M = 1e9+7;
const ll Mxn = 3e5;

ll power(ll i,ll p)
{
	ll ans=1;
	while(p)
	{
		if(p & 1)
			ans = (ans*i)%M;
		i = (i*i)%M;
		p/=2;
	}
	return ans%M;
}
ll Dfunc(ll a)
{
	ll ans=0,len=0;
	ll g=a;
	while(g)
	{
		len++;
		g/=10;
	}
	ans = (a - pow(10,len-1) + 1)*len;
	len--;
	while(len>=1)
	{
		ans+=(pow(10,len)-pow(10,len-1))*len;
		len--;
	}
	return ans;
}
int main()
{
	spd_emergency;
	int t=1;
	//cin>>t;
	while(t--)
	{
		ll c, a, p, ans=0;
		cin>>c>>a>>p;
		ll sub = Dfunc(a);
		ll len=0;
		ll g = a;
		while(g)
		{
			len++;
			g/=10;
		}
		if(len*p > c)
		{
			cout<<0<<endl;
			continue;
		}
		ll low=0,high=1e9+1;
		while(low<=high)
		{
			ll mid = (high-low)/2+low;
			if((Dfunc(a+mid)-sub+len)*p > c)
			{
				high = mid-1;
			}
			else
			{
				//cout<<(Dfunc(a+mid)-sub+len)*p<<endl;
				ans = mid;
				low = mid+1;
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}