比赛 |
2025.10.18 |
评测结果 |
AAAAAWWWWW |
题目名称 |
WHZ 的数字 |
最终得分 |
50 |
用户昵称 |
李奇文 |
运行时间 |
0.999 s |
代码语言 |
C++ |
内存使用 |
7.49 MiB |
提交时间 |
2025-10-18 10:17:46 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+5;
int n,k,f[N];
int main(){
freopen("whz_number.in","r",stdin);
freopen("whz_number.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
while(cin>>n>>k){
memset(f,0,sizeof(f));
bool isc=false;
for(int i=n;i>=1;i--){
int res=i,ans=0;
while(res){
if(res%10==0) ans++;
res/=10;
}
f[i]=f[i+1]+ans;
if(f[i]==k){
isc=true;
cout<<i<<"\n";
break;
}
}
if(isc) continue;
f[0]=f[1]+1;
if(f[0]==k){
cout<<0<<"\n";
}
}
return 0;
}