#include <iostream> using namespace std; int ctprice(int num,int a,int b,int c){ for(int i=9;i>=0;--i){ for(int j=9;j>=0;--j){ int p=i*10000+a*1000+b*100+c*10+j*1; if(p%num==0 && i!=0) {cout<<i<<" "<<j<<" "<<p/num<<endl; return p/num;}; } } cout<<0<<endl; return 0; } int main() { int num; int a,b,c; while(cin>>num>>a>>b>>c){ ctprice(num,a,b,c); } }