题目1036:Old Bill
#include<stdio.h>
int N;
int X;
int Y;
int Z;
int A;
int B;
int ans;
int check(int num){
int sum=N*num;
if((sum/10)%10==Z&&(sum/100)%10==Y&&(sum/1000)%10==X)
{
A=(sum/10000)%10;
B=(sum%10);
ans=num;
return 1;
}
return 0;
}
void output()
{
printf("%d %d %d\n",A,B,ans);
}
int main(int argc, char *argv[])
{
freopen("1036.in","r",stdin);
while(~scanf("%d",&N))
{
scanf("%d %d %d",&X,&Y,&Z);
int M=99999/N;
for(int i=M;;--i)
{
if(check(i)){
output();
break;
}
if(i<=0){
printf("0\n");
break;
}
}
}
return 0;
}