题解
2023-04-15 16:40:32
发布于:上海
60阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int l, r;
cin >> l >> r;
int luckymun = 0, flag =1, ans;
for(int i = l; i <= r; i++){
int m = i, Max = 0, Min = 9;
while(m!=0){
Max = max(Max, m%10);
Min = min(Min, m%10);
m /= 10;
}
if(luckymun < Max - Min) {
luckymun = Max - Min;
ans = i;
}
if(luckymun == 0 && Max - Min == 0) ans = i;
if(luckymun == 9){
cout<< i << endl;
flag=0;
break;
}
}
if(flag != 0){
cout << ans << endl;
}
}
return 0;
}
这里空空如也
有帮助,赞一个