過去ログ

ゴンとも
#51290
>何通りあるのでしょうか? 問題を抜粋しておくので、プログラムを組んで検討して
>いただけないでしょうか。

(3)は7以下も出しましたが8以下も全部出してみました!!
ありふれた問題なんでプログラムは一部書くだけですぐに・・・
有理数モードにすると遅くなるんで普通のモードで・・・

十進Basic で

print time$
FOR a=1 to 10
FOR b=1 to 10
if b=a then goto 80
FOR c=1 to 10
if c=a or c=b then goto 70
FOR d=1 to 10
if d=a or d=b or d=c then goto 60
FOR e=1 to 10
if e=a or e=b or e=c or e=d then goto 50
FOR f=1 to 10
if f=a or f=b or f=c or f=d or f=e then goto 40
FOR g=1 to 10
if g=a or g=b or g=c or g=d or g=e or g=f then goto 30
FOR h=1 to 10
if h=a or h=b or h=c or h=d or h=e or h=f or h=g then goto 20
FOR i=1 to 10
if i=a or i=b or i=c or i=d or i=e or i=f or i=g or i=h then goto 10
FOR j=1 to 10
if j=a or j=b or j=c or j=d or j=e or j=f or j=g or j=h or j=i then goto 5
IF 9*b*d*f*h*j-5*a*d*f*h*j-5*b*c*f*h*j-5*b*d*e*h*j-5*b*d*f*g*j-5*b*d*f*h*i>0 THEN LET s0=s0+1
IF b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN let s1=s1+1
IF 2*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN let s2=s2+1
IF 3*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN let s3=s3+1
IF 4*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN let s4=s4+1
IF 5*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN let s5=s5+1
IF 6*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN let s6=s6+1
IF 7*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN let s7=s7+1
IF 8*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s8=s8+1
IF 9*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s9=s9+1
IF 10*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s10=s10+1
IF 11*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s11=s11+1
IF 12*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s12=s12+1
IF 13*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s13=s13+1
IF 14*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s14=s14+1
IF 15*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s15=s15+1
IF 16*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s16=s16+1
IF 17*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s17=s17+1
IF 18*b*d*f*h*j-a*d*f*h*j-b*c*f*h*j-b*d*e*h*j-b*d*f*g*j-b*d*f*h*i=0 THEN LET s18=s18+1
5 next j
10 next i
20 next h
30 next g
40 next f
50 next e
60 next d
70 next c
80 next b
90 NEXT a
PRINT s0;s1;"+";s2;"+";s3;"+";s4;"+";s5;"+";s6;"+";s7;"=";s1+s2+s3+s4+s5+s6+s7;s8;"+";s9;"+";s10;"+";s11;"+";s12;"+";s13;"+";s14;"+";s15;"+";s16;"+";s17;"+";s18;"=";s8+s9+s10+s11+s12+s13+s14+s15+s16+s17+s18
print time$
END

01:15:11
600 0 + 0 + 360 + 1080 + 720 + 2760 + 1920 = 6840 1080 + 840 + 1320 + 960 + 2640 + 2040 + 1680 + 2040 + 1800 + 960 + 600 = 15960
01:19:38

600通りと6840通りで・・・
あと整数なのは15960+6840=22800通り
あと(4),(5)もあるようですが易問ような・・・
豊川市   2月17日(木) 1:42:35   MAIL:fttnm528@ybb.ne.jp   51294

過去問題一覧へ戻る