求助(样例已过)
查看原帖
求助(样例已过)
1465426
quebinyuan楼主2025/1/18 13:33

怎么办,样例过了,但是测试点有四个WA其他全AC

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int bh(int a){
	int yi,er,san,max=0,min=999;
	yi=a%10;
	er=a/10%10;
	san=a/100%10;
	int at=yi*1+er*10+san*100;
	if(at>max) max=at;
	if(at<min) min=at;
	at=er*1+san*10+yi*100;
	if(at>max) max=at;
	if(at<min) min=at;
	at=san*1+yi*10+er*100;
	if(at>max) max=at;
	if(at<min) min=at;
	at=yi*1+san*10+er*100;
	if(at>max) max=at;
	if(at<min) min=at;
	at=er*1+yi*10+san*100;
	if(at>max) max=at;
	if(at<min) min=at;
	at=san*1+er*10+san*100;
	if(at>max) max=at;
	if(at<min) min=at;
	return max-min;
}
int main(){
	int n,ans=0;
	cin >> n;
	while(n!=495){
		n=bh(n);
		ans++;
	}cout << ans;
	return 0;
}
2025/1/18 13:33
加载中...