提交时间:2026-10-28 13:57:19
运行 ID: 43245
#include <bits/stdc++.h> #define int long long using namespace std; int n,s; int sum(int x){ int t=x,res=0; while(t>0){ res+=t%10; t/=10; } return res; } bool check(int x){ if(x-sum(x)>=s) return 1; return 0; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("num.in","r",stdin); // freopen("num.out","w",stdout); cin>>n>>s; int l=1,r=n; while(l<r){ int mid=(l+r+1)>>1; if(!check(mid)) l=mid; else r=mid-1; } cout<<n-l; return 0; }