#include<iostream> using namespace std; int main() { int d,h,p,t; int as,bs,cs,ds; for(d=1;d<=4;d++) { for(h=1;h<=4;h++) { for(p=1;p<=4;p++) { for(t=1;t<=4;t++) { as=(d==1)+(h==4)+(p==3); bs=(h==1)+(d==4)+(p==2)+(t==3); cs=(h==4)+(d==3); ds=(p==1)+(t==4)+(h==2)+(d==3); if(as+bs+cs+ds==4&&as*bs*cs*ds==1&&d+h+p+t==10&&d*h*p*t==24) cout<<d<<h<<p<<t<<endl; } } } } return 0; }