fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. unsigned long long int r;
  4. int a[5],n,i,j,k,count,g;
  5. int repeat(long int x,int y);
  6. int main(){
  7. int min;
  8. while(~scanf("%d",&n)){
  9. g=0;
  10. min=1234;
  11. if(n<=0)
  12. break;
  13. for(;min<29876;min++){
  14. if(min*n>=98765){
  15. break;
  16. }
  17. k=repeat(min,n);
  18. if(k==1){
  19. if(min<9876){
  20. printf("%d / 0%d = %d\n", min*n, min, n);
  21. g++;
  22. }
  23. else{
  24. printf("%d / %d = %d\n", min*n, min, n);
  25. g++;
  26. }
  27. }
  28. }
  29. if(g==0){
  30. printf("There are no solutions for %d.\n",n);
  31. }
  32. }
  33. }
  34. int repeat(long int x,int y){
  35. count=0;
  36. r=x*y*100000+x;
  37. for(i=0;i<10;i++){
  38. a[i]=r%10;
  39. r/=10;
  40. }
  41. for(i=0;i<10;i++){
  42. for(j=0;j<10;j++){
  43. if(i==j)
  44. continue;
  45. if(a[i]!=a[j])
  46. count++;
  47. }
  48. }
  49. if(count==90)
  50. return 1;
  51. else{
  52. return 0;
  53. }
  54. }
Success #stdin #stdout 0s 4396KB
stdin
61
62
0
stdout
There are no solutions for 61.
79546 / 01283 = 62
94736 / 01528 = 62