为什么都超时。。。弱鸡求助
查看原帖
为什么都超时。。。弱鸡求助
327288
helpcyg楼主2020/6/3 21:23

题目:

直接贴代码

#include<iostream>
using namespace std;
bool same(int A[],int B[],int C[]){
	int times = A[0]*A[1]*A[2]*B[0]*B[1]*B[2]*C[0]*C[1]*C[2],plus = A[0]+A[1]+A[2]+B[0]+B[1]+B[2]+C[0]+C[1]+C[2];
	if((times == 362880)&&(plus == 45)){
		return false;
	}
	return true;
}
int main(){
	int one,two,three,count = 0;
	cin>>one>>two>>three;
	for(int i = 123;i < 988;i++){
		for(int j = i + 1;j < 988;j++){
			for(int h = j + 1;h < 988;h++){
				int a[3],b[3],c[3];
				a[0] = i % 10;
				a[1] = i / 10 % 10;
				a[2] = i / 100;
				
				b[0] = j % 10;
				b[1] = j / 10 % 10;
				b[2] = j / 100;
				
				c[0] = h % 10;
				c[1] = h / 10 % 10;
				c[2] = h / 100;		
				if(j % i == 0 && h % i == 0){
					if((j / i == two && h / i == three) && (!same(a,b,c))){
						cout<<i<<" "<<j<<" "<<h<<endl;
						count++;
					}
				}
			}
		}
	}
	if(count == 0){
		cout<<"No!!!";
	}
	return 0;
}
2020/6/3 21:23
加载中...