| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 43244 | _Yuyuyu_ | 【J】T1 | C++ | 通过 | 100 | 0 MS | 256 KB | 572 | 2026-10-28 13:57:17 |
#include<bits/stdc++.h> using namespace std; #define int long long int n,s,ans; bool check(int k){ if(k>n||k==0)return 0; int t=k,sum=0; while(k){ sum+=k%10; k/=10; } return t-sum>=s; } signed main(){ cin>>n>>s; ans=0; int l=1,r=n; while(l<=r){ int mid=(l+r)>>1; if(check(mid)){ ans=mid; r=mid-1; } else l=mid+1; } if(ans==0)cout<<0<<endl; else cout<<n-ans+1<<endl; return 0; } /* 1:枚举每一位 2:二分 */