Advertisement
erfanul007

Untitled

Nov 25th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a,b,c,d,e,f,g,h,i,j,n,number,div,mod[15],tmp,cn,pk;
  5. freopen("input.txt","r",stdin);
  6. while(1){
  7. scanf("%d",&n);
  8. if(n==0)
  9. break;
  10. cn=0;
  11. for(a=0;a<=9;a++){
  12. for(b=0;b<=9;b++){
  13. if(b==a)
  14. continue;
  15. for(c=0;c<=9;c++){
  16. if(c==b || c==a)
  17. continue;
  18. for(d=0;d<=9;d++){
  19. if(d==a || d==b || d==c)
  20. continue;
  21. for(e=0;e<=9;e++){
  22. if(e==a || e==b || e==c || e==d)
  23. continue;
  24. mod[1]=a;
  25. mod[2]=b;
  26. mod[3]=c;
  27. mod[4]=d;
  28. mod[5]=e;
  29. i=5;
  30. number=a*10000+b*1000+c*100+d*10+e;
  31. div=number*n;
  32. if(div<100000 && div>9999){
  33. tmp=div;
  34. pk=0;
  35. while(div!=0){
  36. i++;
  37. mod[i]=div%10;
  38. for(j=i-1;j>0;j--){
  39. if(mod[i]==mod[j]){
  40. pk++;
  41. break;
  42. }
  43. }
  44. if(pk!=0)
  45. break;
  46. div=div/10;
  47. }
  48. if(pk==0){
  49. printf("%05d / %05d = %d\n",tmp,number,n);
  50. cn++;
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. if(cn==0)
  59. printf("There are no solutions for %d.\n",n);
  60. printf("\n");
  61. }
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement