#7 WA #1RE 其他 AC 求大佬看看
查看原帖
#7 WA #1RE 其他 AC 求大佬看看
793555
sunyinghang楼主2023/10/20 20:49
#include<bits/stdc++.h>
using namespace std;
int a[66],r,b,c,q,w,e;
bool u[66],f;
void dg(int dep)
{
	if(dep>9)
	{
		q=a[1]*100+a[2]*10+a[3];
		w=a[4]*100+a[5]*10+a[6];
		e=a[7]*100+a[8]*10+a[9];
		if(q/r*b==w&&w/b*c==e)
		{
			cout<<q<<' '<<w<<' '<<e<<'\n';
			f=1;	
		} 
	}
	else
	{
		for(int i=1;i<=9;i++)
		{
			if(!u[i])
			{
				a[dep]=i;
				u[i]=1;
				dg(dep+1);
				u[i]=0;
			}
		}
	}
}
int main()
{
	cin>>r>>b>>c;
	dg(1); 
	if(f==0)
	{
		cout<<"No!!!";
	}
	return 0;
}
2023/10/20 20:49
加载中...