Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int a,b,c,d,e,f,g,h,i,j,n,number,div,mod[15],tmp,cn,pk;
- freopen("input.txt","r",stdin);
- while(1){
- scanf("%d",&n);
- if(n==0)
- break;
- cn=0;
- for(a=0;a<=9;a++){
- for(b=0;b<=9;b++){
- if(b==a)
- continue;
- for(c=0;c<=9;c++){
- if(c==b || c==a)
- continue;
- for(d=0;d<=9;d++){
- if(d==a || d==b || d==c)
- continue;
- for(e=0;e<=9;e++){
- if(e==a || e==b || e==c || e==d)
- continue;
- mod[1]=a;
- mod[2]=b;
- mod[3]=c;
- mod[4]=d;
- mod[5]=e;
- i=5;
- number=a*10000+b*1000+c*100+d*10+e;
- div=number*n;
- if(div<100000 && div>9999){
- tmp=div;
- pk=0;
- while(div!=0){
- i++;
- mod[i]=div%10;
- for(j=i-1;j>0;j--){
- if(mod[i]==mod[j]){
- pk++;
- break;
- }
- }
- if(pk!=0)
- break;
- div=div/10;
- }
- if(pk==0){
- printf("%05d / %05d = %d\n",tmp,number,n);
- cn++;
- }
- }
- }
- }
- }
- }
- }
- if(cn==0)
- printf("There are no solutions for %d.\n",n);
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement