fork download
  1. #module
  2. #deffunc swap var a, var b, local c
  3. c=a
  4. a=b
  5. b=c
  6. return
  7.  
  8.  
  9. #defcfunc gcd int a, int b, local x, local y, local z
  10. x=a
  11. y=b
  12. repeat
  13. z=x\y
  14. if z=0 : break
  15. x=y
  16. y=z
  17. loop
  18. return y
  19.  
  20.  
  21. #deffunc fuga array ru, array rl, var rnum, local u, local l
  22. rnum=0
  23. repeat 9, 1
  24. l=cnt
  25. repeat l-1, 1
  26. u=cnt
  27. if gcd(u, l)!1 : continue
  28. ru.rnum=u
  29. rl.rnum=l
  30. rnum++
  31. loop
  32. loop
  33. return rnum
  34.  
  35.  
  36. #defcfunc dec var x
  37. if x<=0 : return 0
  38. x--
  39. return 1
  40.  
  41.  
  42. #deffunc check int number, int used, var count, array ru, array rl, int rnum, \
  43. local dcount_org, local dcount, local n, local u, local breaked
  44.  
  45. dim dcount_org, 10
  46. dim dcount, 10
  47. n=number
  48. repeat used
  49. dcount_org(n\10)++
  50. n/=10
  51. loop
  52.  
  53. repeat rnum
  54. if number\rl.cnt : continue
  55. memcpy dcount, dcount_org, 4*10
  56. if dcount(ru.cnt) : continue
  57. if dec(dcount(rl.cnt))=0 : continue
  58. dcount(ru.cnt)++
  59. u=ru.cnt*(number/rl.cnt)
  60. breaked=0
  61. repeat used
  62. if dec(dcount(u\10))=0 {
  63. breaked=1
  64. break
  65. }
  66. u/=10
  67. loop
  68. if breaked : continue
  69.  
  70. logmes strf("%d / %d", ru.cnt*(number/rl.cnt), number)
  71.  
  72. count++
  73. loop
  74. return
  75.  
  76.  
  77. #deffunc hoge int number, array digit, int used, var count, array ru, array rl, int rnum, \
  78. local d
  79.  
  80. if used : check number, used, count, ru, rl, rnum
  81. repeat 9-used
  82. d=digit(cnt)
  83. swap digit(cnt), digit(9-1-used)
  84. hoge number*10+d, digit, used+1, count, ru, rl, rnum
  85. swap digit(cnt), digit(9-1-used)
  86. loop
  87. await
  88. return
  89.  
  90.  
  91. #deffunc solve local count, local digit, local ru, local rl, local rnum
  92. fuga ru, rl, rnum
  93. repeat 9
  94. digit.cnt=cnt+1
  95. loop
  96. hoge 0, digit, 0, count, ru, rl, rnum
  97. return count
  98.  
  99.  
  100. #global
  101.  
  102.  
  103. solve
  104. mes stat
  105. ; 14.4 sec
  106. ; 349
  107.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty