1 条题解

  • 0
    @ 2026-8-28 15:18:01

    思路

    不难发现,数字越大,他的价值越大,因此使用二分直接求解即可。

    AC代码

    #include<bits/stdc++.h>
    #define int long long
    using namespace std;
    const int N=2e5+10;
    int cal(int x)
    {
    	int res=0;
    	while(x)x/=10,res++;
    	return res;
    }
    signed main()
    {
    	int a,b,n;scanf("%lld%lld%lld",&a,&b,&n);
    	int l=0,r=1000000000,ans=0;
    	while(l<=r)
    	{
    		int mid=l+r>>1;
    		if(a*mid+b*cal(mid)<=n)l=mid+1,ans=mid;
    		else r=mid-1;
    	}
    	printf("%lld\n",ans);
    	return 0;
    }
    
    • 1

    信息

    ID
    11772
    时间
    2000ms
    内存
    1024MiB
    难度
    6
    标签
    递交数
    16
    已通过
    12
    上传者