感觉思路没错,但是没过
查看原帖
感觉思路没错,但是没过
483058
陈泽涵爱g编程楼主2021/10/5 20:08
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int a[101],b[101],c[101];
void dfs(int aa,int bb,int cc,int step){
	if(step>20000){
		cout<<"NONE";
		exit(0);
	}
	if(aa*a[2]+bb*a[4]+cc*a[3]==step*a[1]&&aa*b[2]+bb*b[4]+cc*b[3]==step*b[1]&&aa*c[2]+bb*c[4]+cc*c[3]==step*c[1]){
		cout<<aa<<" "<<bb<<" "<<cc<<" "<<step;
		exit(0);
	}
	if(aa*a[2]+bb*a[4]+cc*a[3]>step*a[1]||aa*b[2]+bb*b[4]+cc*b[3]>step*b[1]||aa*c[2]+bb*c[4]+cc*c[3]>step*c[1]){
		dfs(aa,bb,cc,++step);
	}
	dfs(++aa,bb,cc,step);
	dfs(aa,++bb,cc,step);
	dfs(aa,bb,++cc,step);
}
int main(){
    ios::sync_with_stdio(false);
    for(int i=1;i<=4;i++){
    	cin>>a[i]>>b[i]>>c[i];
	}
	dfs(0,0,0,1);
	return 0;
}

2021/10/5 20:08
加载中...