找一定范围内的末尾9最多的数,很神啊(先找0最多的,一减,o)。之前那里加一,最后减一。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
typedef __int64 ll;
using namespace std;
//枚举行不?
__int64 p,d;
int main(){
scanf("%I64d%I64d",&p,&d);
ll weig = 10,ans = p + 1;
p ++;
while(p % weig <= d){//这里就是小于等于d
ans = p - p % weig;
weig *= 10;
}
printf("%I64d\n",ans - 1);
return 0;
}
本文介绍了一种算法,用于在指定范围内找到末尾9出现次数最多的数。通过逐步增加数值并检查其末尾9的数量,最终确定符合条件的最大数。
2828

被折叠的 条评论
为什么被折叠?



