0pts求调(2关)
查看原帖
0pts求调(2关)
1403206
adminin楼主2025/1/16 20:14
#include<bits/stdc++.h>
using namespace std;
int A,B,C,a[5]={0,0,C};
bool m[25],vis[25][25][25];
int sw(int x){
	if(x==1)return A;
	if(x==2)return B;
	if(x==3)return C;
}
void DFS(){
	if(vis[a[1]][a[2]][a[3]])return;
	vis[a[1]][a[2]][a[3]]=1;
	if(!a[1])m[a[3]]=1;
	for(int i=1;i<=3;i++)
	for(int j=1;j<=3;j++)if(i!=j&&a[i]>0&&a[j]<sw(j)){
		int res=min(sw(j)-a[j],a[i]);
		a[j]+=res,a[i]-=res;
		DFS();
		a[j]-=res,a[i]+=res;
	}
}
int main(){
	cin>>A>>B>>C;
	DFS();
	for(int i=1;i<C;i++)
	if(m[i])cout<<i<<" ";
	cout<<C<<endl;
}

疯了。。。

2025/1/16 20:14
加载中...