◆東京都 明 さんからの解答
【問題1】
○,○,×,×,×, ×,×,×,◎,◎, ×,×,×,×,◎, ○,×,×,×,×, ×,×,◎,◎,×【問題2】
基本的な配列は1通り。
回転(4種類)、裏返し(2種類)で8通りとなります。
【問題3】
まず豚2匹の基本配置を以下のように洗い出し、縦、横、斜めをつぶして、5箇所以上の空きができるものを拾い上げ、さらに一匹を追加して、最終的に5箇所の空きが残るものを拾いあげました。
結果、3つ(同型)を見つけました。
中央に1匹がいる場合(5通り)
中央になく、内周に少なくとも1匹の場合(24通り)
外周のみに2匹の場合(21通り)
論理的な決定法がわかりませんので洗い出しのプログラムを「(仮称)十進BASIC」で作ってみました。
これで計算すると、豚とライオンの関係は下記のようになります。
豚 ライオン 解の数 0 25 1 1 12 16 2 7 24 3 5 8 4 4 18 5 3 8 6 2 246 7 2 24 8 1(これ以後は時間がかかりすぎるので ・ ・ 実行していません。) 12 1 16 13 0 ? ・ ・ 25 0 1ライオン(または豚)の数が0となる場合 の解の数は、25個から豚(またはライオン)の数を選ぶ 組み合わせの数となると思います。
【コメント】
広島県 清川 育男 さんからの情報によると、次のような結果になるそうです。
豚 ライオン 解の数 0 25 1 ・ ・ ・ 1 13 0 1 12 16 1 11 192 1 10 1064 1 9 3600 1 8 8281 2 7 24 3 5 8 4 4 18 5 3 8 6 2 246 7 2 24 8 1 8281 9 1 3600 10 1 1064 11 1 192 12 1 16 13 1 0 ・ ・ ・ 25 0 1 ◆明さんのプログラム DECLARE EXTERNAL SUB ZYUN LET A=5 ! 配列数定義 LET W=3 ! 監視人数定義(豚の数) DIM ARAY(A,A) ! 配置領域定義 DIM KANS(A,A) ! 監視人配置パターン領域定義 REM 基準配列の生成 LET HN=A*A ! 配置領域数 DIM N(HN) MAT N=ZER LET WW=W FOR I=HN TO 1 STEP -1 IF WW>0 THEN LET N(I)=1 LET WW=WW-1 END IF NEXT I REM 監視もれ数の最大値を求める LET ZO=0 ! 監視もれ数 LET AC=0 ! 適合配列数 LET NO=0 ! 配置No DO MAT ARAY=ZER LET NO=NO+1 FOR I=1 TO HN IF N(I)=1 THEN CALL KANSI NEXT I CALL ZANSUU IF ZN>ZO THEN LET ZO=ZN LET AC=1 ELSEIF ZN=ZO THEN LET AC=AC+1 END IF CALL ZYUN(HN,EX,N) LOOP WHILE EX=1 PRINT "配列 : ";A;"×";A;" 監視人数 : ";W IF ZO=0 THEN PRINT "NOTHING" STOP END IF PRINT "CHECK数 : ";NO;" 適合配列個数 : ";AC;" 監視もれ数 : ";ZO REM 監視もれ数が最大の監視人配置を求める MAT N=ZER LET NO=0 ! 配置No LET WW=W FOR I=HN TO 1 STEP -1 IF WW>0 THEN LET N(I)=1 LET WW=WW-1 END IF NEXT I DO LET NO=NO+1 MAT ARAY=ZER MAT KANS=ZER FOR I=1 TO HN IF N(I)=1 THEN CALL KANSI LET KANS(X,Y)=1 END IF NEXT I CALL ZANSUU IF ZN=ZO THEN PRINT PRINT "CHECK No : ";NO CALL OUTPUT END IF CALL ZYUN(HN,EX,N) LOOP WHILE EX=1 PRINT PRINT "END" STOP SUB KANSI ! 監視範囲の塗りつぶし LET X=INT((I-1)/A)+1 LET Y=MOD((I-1),A)+1 FOR J=1 TO A LET ARAY(X,J)=1 LET ARAY(J,Y)=1 NEXT J LET DX=1 LET DY=1 FOR J=1 TO 4 CALL NANAME LET DX=DX*DY LET DY=-DY NEXT J END SUB SUB NANAME ! 斜め方向の塗りつぶし LET XX=X LET YY=Y DO UNTIL XX=0 OR XX=A+1 OR YY=0 OR YY=A+1 LET ARAY(XX,YY)=1 LET XX=XX+DX LET YY=YY+DY LOOP END SUB SUB ZANSUU !監視残数のCHECK LET ZN=0 FOR I=1 TO A FOR J=1 TO A IF ARAY(I,J)=0 THEN LET ZN=ZN+1 NEXT J NEXT I END SUB SUB OUTPUT ! 結果配列の出力 FOR I=1 TO A FOR J=1 TO A IF KANS(I,J)=1 THEN PRINT "○ "; ELSEIF ARAY(I,J)=0 THEN PRINT "◎ "; ELSE PRINT "× "; END IF NEXT J PRINT NEXT I END SUB END !順列の変更 EXTERNAL SUB ZYUN(K,EX,N()) DECLARE EXTERNAL SUB SEIRETU LET EX=0 LET J=1 DO IF J>=K THEN EXIT DO IF N(K-J)<N(K-J+1) THEN CALL SEIRETU(J,K,N) LET L=1 DO IF N(K-J)>=N(K-J+L) THEN LET L=L+1 ELSE LET B=N(K-J) LET N(K-J)=N(K-J+L) LET N(K-J+L)=B LET EX=1 EXIT DO END IF LOOP EXIT DO ELSE LET J=J+1 END IF LOOP END SUB !配列の整列 EXTERNAL SUB SEIRETU(J,K,N()) LET D=K-J+1 LET E=K DO WHILE D<E LET B=N(D) LET N(D)=N(E) LET N(E)=B LET D=D+1 LET E=E-1 LOOP END SUB
◆千葉県 菜花子 さんからの解答
【問題1】
×,◎,◎,×,×, ×,◎,×,×,◎, ×,×,×,×,◎, ○,×,×,×,×, ○,×,×,○,× -------------------- ×,×,◎,◎,×, ◎,×,×,◎,×, ◎,×,×,×,×, ×,×,×,×,○, ×,○,×,×,○ -------------------- ×,×,◎,◎,×, ○,×,×,×,×, ×,×,×,×,◎, ×,×,×,◎,◎, ○,○,×,×,× -------------------- ×,◎,◎,×,×, ×,×,×,×,○, ◎,×,×,×,×, ◎,◎,×,×,×, ×,×,×,○,○ -------------------- ○,×,×,○,×, ○,×,×,×,×, ×,×,×,×,◎, ×,◎,×,×,◎, ×,◎,◎,×,× -------------------- ×,○,×,×,○, ×,×,×,×,○, ◎,×,×,×,×, ◎,×,×,◎,×, ×,×,◎,◎,× -------------------- ○,○,×,×,×, ×,×,×,◎,◎, ×,×,×,×,◎, ○,×,×,×,×, ×,×,◎,◎,× -------------------- ×,×,×,○,○, ◎,◎,×,×,×, ◎,×,×,×,×, ×,×,×,×,○, ×,◎,◎,×,×【問題2】
8通り
【問題3】
◆広島県 清川 育男 さんからの解答
●予想
(2n+1)*(2n+1)
豚(ライオン) | ライオン(豚) |
2n-1個 | (3n2-3n+4)/2個 |
5*5 1 ○,○,×,×,×, ×,×,×,△,△, ×,×,×,×,△, ○,×,×,×,×, ×,×,△,△,×, 2 ○,×,×,○,×, ○,×,×,×,×, ×,×,×,×,△, ×,△,×,×,△, ×,△,△,×,×, 3 ×,○,×,×,○, ×,×,×,×,○, △,×,×,×,×, △,×,×,△,×, ×,×,△,△,×, 4 ×,×,×,○,○, △,△,×,×,×, △,×,×,×,×, ×,×,×,×,○, ×,△,△,×,×, 5 ×,×,△,△,×, ○,×,×,×,×, ×,×,×,×,△, ×,×,×,△,△, ○,○,×,×,×, 6 ×,△,△,×,×, ×,×,×,×,○, △,×,×,×,×, △,△,×,×,×, ×,×,×,○,○, 7 ×,△,△,×,×, ×,△,×,×,△, ×,×,×,×,△, ○,×,×,×,×, ○,×,×,○,×, 8 ×,×,△,△,×, △,×,×,△,×, △,×,×,×,×, ×,×,×,×,○, ×,○,×,×,○, 7*7 1 ○,×,○,×,×,×,○, ×,×,×,×,△,×,×, ×,△,×,△,×,△,×, ×,△,×,×,△,×,×, ×,△,×,△,×,△,×, ×,×,×,△,△,×,×, ○,×,×,×,×,×,○, 2 ○,×,×,×,○,×,○, ×,×,△,×,×,×,×, ×,△,×,△,×,△,×, ×,×,△,×,×,△,×, ×,△,×,△,×,△,×, ×,×,△,△,×,×,×, ○,×,×,×,×,×,○, 3 ○,×,×,×,×,×,○, ×,×,△,△,△,×,×, ○,×,×,×,×,×,×, ×,×,△,×,△,△,×, ×,△,×,△,×,△,×, ×,×,△,×,△,×,×, ○,×,×,×,×,×,○, 4 ○,×,×,×,×,×,○, ×,×,△,△,△,×,×, ×,×,×,×,×,×,○, ×,△,△,×,△,×,×, ×,△,×,△,×,△,×, ×,×,△,×,△,×,×, ○,×,×,×,×,×,○, 5 ○,×,×,×,×,×,○, ×,×,△,×,△,×,×, ×,△,×,△,×,△,×, ×,×,△,×,△,△,×, ○,×,×,×,×,×,×, ×,×,△,△,△,×,×, ○,×,×,×,×,×,○, 6 ○,×,×,×,×,×,○, ×,×,△,×,△,×,×, ×,△,×,△,×,△,×, ×,△,△,×,△,×,×, ×,×,×,×,×,×,○, ×,×,△,△,△,×,×, ○,×,×,×,×,×,○, 7 ○,×,×,×,×,×,○, ×,×,×,△,△,×,×, ×,△,×,△,×,△,×, ×,△,×,×,△,×,×, ×,△,×,△,×,△,×, ×,×,×,×,△,×,×, ○,×,○,×,×,×,○, 8 ○,×,×,×,×,×,○, ×,×,△,△,×,×,×, ×,△,×,△,×,△,×, ×,×,△,×,×,△,×, ×,△,×,△,×,△,×, ×,×,△,×,×,×,×, ○,×,×,×,○,×,○, 9*9 1 ○,○,×,×,×,×,×,×,○, ×,×,×,△,△,△,△,×,×, ×,×,×,×,△,△,×,△,×, ×,×,△,×,×,×,△,△,×, ×,×,△,△,×,×,△,△,×, ×,×,△,×,△,×,×,△,×, ×,×,×,△,△,△,×,×,×, ×,○,×,×,×,×,×,×,○, ○,×,×,×,×,×,×,×,○, 2 ○,×,○,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×, ○,×,○,×,×,×,×,×,×, ×,×,×,×,△,×,△,△,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,×,×,△,△,×,△,×,×, ○,×,×,×,×,×,×,×,○, 3 ○,×,○,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×, ×,×,×,×,×,×,×,×,○, ×,△,×,×,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,×,×,×,△,△,△,×,×, ○,×,○,×,×,×,×,×,○, 4 ○,×,○,×,×,×,×,×,○, ×,×,×,×,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,△,×, ×,△,×,△,×,△,×,△,×, ×,×,×,×,△,×,△,×,×, ○,×,×,×,×,×,×,×,○, ×,×,×,△,△,△,△,×,×, ○,×,×,×,×,×,×,×,○, 5 ○,×,○,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,△,×, ×,△,×,△,×,△,×,△,×, ×,×,×,×,△,×,△,×,×, ×,×,○,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×, ○,×,×,×,×,×,×,×,○, 6 ○,×,○,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×, ×,×,×,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×, ○,×,○,×,×,×,×,×,○, 7 ○,×,×,×,×,×,○,×,○, ×,×,△,△,△,×,×,×,×, ○,×,×,×,×,×,×,×,×, ×,×,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,×,△,△,△,×,×,×,×, ○,×,×,×,×,×,○,×,○, 8 ○,×,×,×,×,×,○,×,○, ×,×,△,△,△,×,×,×,×, ×,×,×,×,×,×,○,×,○, ×,△,△,×,△,×,×,×,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,△,×,×,×, ○,×,×,×,×,×,×,×,○, 9 ○,×,×,×,×,×,○,×,○, ×,×,△,△,△,×,×,×,×, ×,△,×,△,×,△,×,△,×, ×,△,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,×,×,×,×, ○,×,×,×,×,×,○,×,×, ×,×,△,△,△,×,×,×,×, ○,×,×,×,×,×,×,×,○, 10 ○,×,×,×,×,×,○,×,○, ×,×,△,×,△,×,×,×,×, ×,△,×,△,×,△,×,△,×, ×,△,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,×,×,×,×, ○,×,×,×,×,×,×,×,○, ×,×,△,△,△,△,×,×,×, ○,×,×,×,×,×,×,×,○, 11 ○,×,×,×,×,×,○,×,○, ×,×,△,△,△,×,×,×,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,×,×,△,×, ○,×,×,×,×,×,×,×,×, ×,×,△,△,△,×,×,×,×, ○,×,×,×,×,×,○,×,○, 12 ○,×,×,×,×,×,×,○,○, ×,×,△,△,△,△,×,×,×, ×,△,×,△,△,×,×,×,×, ×,△,△,×,×,×,△,×,×, ×,△,△,×,×,△,△,×,×, ×,△,×,×,△,×,△,×,×, ×,×,×,△,△,△,×,×,×, ○,×,×,×,×,×,×,○,×, ○,×,×,×,×,×,×,×,○, 13 ○,×,×,×,×,×,×,×,○, ○,×,×,×,×,×,×,○,×, ×,×,×,△,△,△,×,×,×, ×,△,×,×,△,×,△,×,×, ×,△,△,×,×,△,△,×,×, ×,△,△,×,×,×,△,×,×, ×,△,×,△,△,×,×,×,×, ×,×,△,△,△,△,×,×,×, ○,×,×,×,×,×,×,○,○, 14 ○,×,×,×,×,×,×,×,○, ×,○,×,×,×,×,×,×,○, ×,×,×,△,△,△,×,×,×, ×,×,△,×,△,×,×,△,×, ×,×,△,△,×,×,△,△,×, ×,×,△,×,×,×,△,△,×, ×,×,×,×,△,△,×,△,×, ×,×,×,△,△,△,△,×,×, ○,○,×,×,×,×,×,×,○, 15 ○,×,×,×,×,×,×,×,○, ×,×,△,△,△,×,×,×,×, ○,×,×,×,×,×,○,×,×, ×,×,△,×,△,×,×,×,×, ×,△,×,△,×,△,×,△,×, ×,△,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,×,△,△,△,×,×,×,×, ○,×,×,×,×,×,○,×,○, 16 ○,×,×,×,×,×,×,×,○, ×,×,×,△,△,△,△,×,×, ○,×,×,×,×,×,×,×,○, ×,×,×,×,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,△,×, ×,△,×,△,×,△,×,△,×, ×,×,×,×,△,×,△,×,×, ○,×,○,×,×,×,×,×,○, 17 ○,×,×,×,×,×,×,×,○, ×,×,△,△,△,△,×,×,×, ○,×,×,×,×,×,×,×,○, ×,×,△,×,△,×,×,×,×, ×,△,×,△,×,△,×,△,×, ×,△,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,×,×,×,×, ○,×,×,×,×,×,○,×,○, 18 ○,×,×,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×, ×,×,○,×,×,×,×,×,○, ×,×,×,×,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,△,×, ×,△,×,△,×,△,×,△,×, ×,×,×,×,△,△,△,×,×, ○,×,○,×,×,×,×,×,○, 19 ○,×,×,×,×,×,×,×,○, ×,×,×,△,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×, ×,△,×,△,×,△,×,△,×, ×,×,×,×,△,×,△,△,×, ○,×,○,×,×,×,×,×,×, ×,×,×,×,△,△,△,×,×, ○,×,○,×,×,×,×,×,○, 20 ○,×,×,×,×,×,×,×,○, ×,×,△,×,△,△,×,×,×, ×,△,×,△,×,△,×,△,×, ×,×,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×, ×,△,△,×,△,×,×,×,×, ×,×,×,×,×,×,○,×,○, ×,×,△,△,△,×,×,×,×, ○,×,×,×,×,×,○,×,○, 予想の変更の可能性。 11*11 ○,×,○,×,×,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×,×,×, ○,×,○,×,×,×,×,×,○,×,○, ×,×,×,×,△,×,△,×,×,×,×, ×,△,×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×,×,×, ×,△,×,△,△,△,×,△,×,△,×, ×,×,×,△,△,△,△,×,×,×,×, ×,×,×,×,×,×,×,×,○,×,○, 9-32 ○,×,○,×,×,×,×,×,×,×,○, ×,×,×,×,△,△,△,×,×,×,×, ○,×,○,×,×,×,×,×,○,×,○, ×,×,×,×,△,×,△,×,×,×,×, ×,△,×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×,△,×, ×,△,×,△,×,△,×,△,×,△,×, ×,△,×,×,△,×,△,×,×,×,×, ×,△,×,△,△,△,×,△,×,△,×, ×,×,×,△,△,△,△,×,×,×,×, ○,×,×,×,×,×,×,×,○,×,○, 10-32
◆ 問題へもどる
◆ 今週の問題へ