#include <stdio.h>
int main()
{
int n,
a[10],i,flag,n1,nc,r,j,t1,t;
scanf("%d",&t);
for(t1=1;t1<=t;t1++)
{
nc=0;
for(i=0;i<10;i++)
a[i]=-1;
scanf("%d",&n);
for(i=0;i<45;i++)
{
n1=n*(i+1);
while(n1>0)
{
flag=0;
r=n1%10;
for(j=0;j<10;j++)
{
if(a[j]
== r)
{
flag=1;
break;
}
}
if(flag
== 0 && nc < 10)
{
a[nc]=n1%10;
nc++;
}
n1=n1/10;
}
if(nc
== 10)
{
printf("Case
#%d:%d",t1,n*(i+1));
break;
}
}
if(nc < 10)
printf("Case
#%d:%s",t1,"INSOMNIA");
}
}
No comments:
Post a Comment