Advertisement
erfanul007

UVa 725

Nov 26th, 2018
173
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,w=0;
  5. while(1){
  6. scanf("%d",&n);
  7. if(n==0)
  8. break;
  9. if(w>0)
  10. printf("\n");
  11. w++;
  12. cn=0;
  13. for(a=0;a<=9;a++){
  14. for(b=0;b<=9;b++){
  15. if(b==a)
  16. continue;
  17. for(c=0;c<=9;c++){
  18. if(c==b || c==a)
  19. continue;
  20. for(d=0;d<=9;d++){
  21. if(d==a || d==b || d==c)
  22. continue;
  23. for(e=0;e<=9;e++){
  24. if(e==a || e==b || e==c || e==d)
  25. continue;
  26. mod[1]=a;
  27. mod[2]=b;
  28. mod[3]=c;
  29. mod[4]=d;
  30. mod[5]=e;
  31. i=5;
  32. number=a*10000+b*1000+c*100+d*10+e;
  33. div=number*n;
  34. if(div<100000 && div>9999){
  35. tmp=div;
  36. pk=0;
  37. while(div!=0){
  38. i++;
  39. mod[i]=div%10;
  40. for(j=i-1;j>0;j--){
  41. if(mod[i]==mod[j]){
  42. pk++;
  43. break;
  44. }
  45. }
  46. if(pk!=0)
  47. break;
  48. div=div/10;
  49. }
  50. if(pk==0){
  51. printf("%05d / %05d = %d\n",tmp,number,n);
  52. cn++;
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. if(cn==0)
  61. printf("There are no solutions for %d.\n",n);
  62. }
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement