過去ログ

ゴンとも
#42007

>wxMaxima で、1から5の場合をプログラムしてみました。(以下の通り)
>実行結果、316.5秒で答えが出ました。

2014年だから6年前ですか?!自分もやってみました!!
十進Basic で

(a)(b)(c)(d)(e)
(f)(g)(h)(i)(j)
(k)(l)(m)(n)(o)
(p)(q)(r)(s)(t) と変数を振り以下のコードで

print time$
for a=1 to 5
for b=1 to 5
for c=1 to 5
for d=1 to 5
for e=1 to 5
if a+b+c+d+e<>15 or a*b*c*d*e<>120 then goto 160
for f=1 to 5
if f=a then goto 150
for g=1 to 5
if g=b then goto 140
for h=1 to 5
if h=c then goto 130
for i=1 to 5
if i=d then goto 120
for j=1 to 5
if j=e then goto 110
if f+g+h+i+j<>15 or f*g*h*i*j<>120 then goto 110
for k=1 to 5
if k=a or k=f then goto 100
for l=1 to 5
if l=b or l=g then goto 90
for m=1 to 5
if m=c or m=h then goto 80
for n=1 to 5
if n=d or n=i then goto 70
for o=1 to 5
if o=e or o=j then goto 60
if k+l+m+n+o<>15 or k*l*m*n*o<>120 then goto 60
for p=1 to 5
if p=a or p=f or p=k then goto 50
for q=1 to 5
if q=b or q=g or q=l then goto 40
for r=1 to 5
if r=c or r=h or r=m then goto 30
for s=1 to 5
if s=d or s=i or s=n then goto 20
for t=1 to 5
if t=e or t=j or t=o then goto 10
if p+q+r+s+t<>15 or p*q*r*s*t<>120 then goto 10
let s1=s1+1
10 next t
20 next s
30 next r
40 next q
50 next p
60 next o
70 next n
80 next m
90 next l
100 next k
110 next j
120 next i
130 next h
140 next g
150 next f
160 next e
170 next d
180 next c
190 next b
200 next a
print s1
print time$
end

20:38:04
161280
20:38:11

で7秒でした!!

>しかし、1から6の場合を計算するには、もっと工夫しないと・・・
>数百時間もかかりそうです(^^;;

今からやろうと思います!!
けど数百時間もかかるのならできませんよね〜何日も。
豊川市   1月21日(木) 20:50:15   MAIL:fttnm528@ybb.ne.jp   50051

過去問題一覧へ戻る