有一个样例超时了 求助
查看原帖
有一个样例超时了 求助
1013331
HE240214楼主2024/7/29 14:29
#include<bits/stdc++.h>
using namespace std;
const int N=10;
int a,b,c;
bool st[N];
bool check(int u) {
	if(u<100||u>999) {
		return false;
	}
	int x=u/100;
	int y=u/10%10;
	int z=u%10;
	if(x==y||y==z||x==z) {
		return false;
	}
	if(st[x]||st[y]||st[z]) {
		return false;
	}
	return st[x]=st[y]=st[z]=true;
}
int main() {
	cin>>a>>b>>c;
	bool flag=false;
	for(int i=123; i<=987; i++) {
		memset(st,0,sizeof(st));
		st[0]=true;
		if(!check(i)) {
			continue;
		}
		if(i*b%a) {
			continue;
		}
		int j=i*b/a;
		if(!check(j)) {
			continue;

		}
		int k=j*c/b;
		if(!check(k)) {
			continue;
		}
		cout<<i<<' '<<j<<' '<<k<<endl;
		flag=true;
	}
	if(!flag) {
		cout<<"No!!!";
	}
	return 0;
}
2024/7/29 14:29
加载中...