为什么输出全正确还会wa
查看原帖
为什么输出全正确还会wa
700689
YTZJZYC楼主2023/10/16 20:46

评测记录

我下载了数据,有个和样例一样的,结果就是过不去,非加强版也是一样,直接输出最终结果才过去的

感谢大佬!!!!

#include<iostream>
using namespace std;
int a1,b1,c1;
bool f=1;

void dfs(bool a[],int s,int l[]){
	if(s==9){
		int x=l[1]*100+l[2]*10+l[3];
		int y=l[4]*100+l[5]*10+l[6];
		int z=l[7]*100+l[8]*10+l[9];
		if((x*c1)==(z*a1)&&(x*b1)==(y*a1)){
			cout<<x<<" "<<y<<" "<<z<<endl;
			f=0;
		}
	}else{
		for(int i=1;i<=9;i++){
			if(a[i]==0){
				s++;
				l[s]=i;
				a[i]=1;
				dfs(a,s,l);
				a[i]=0;
				s--;
			} 
		}
	}
	return;
}
int main(){
	cin>>a1>>b1>>c1;
	int c[20];
	bool d[20];
	dfs(d,0,c);
	if(f) puts("No!!!");
	return 0;
} 
2023/10/16 20:46
加载中...