結果

問題 No.58 イカサマなサイコロ
ユーザー jjjj
提出日時 2016-08-25 00:34:20
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,275 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 27,768 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 20:47:57
合計ジャッジ時間 684 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::win=0,total,taro_sum,jiro_sum
  integer::N,K,i,j
  integer::taro(60),jiro(60)
  integer,parameter::dice(6)=(/1,1,1,1,1,1/), &
                     dice2(6)=(/0,0,0,2,2,2/)
  data taro/60*0/,jiro/60*0/

  read *,N,K

  jiro(1:6) = dice(1:6)
  call cast_dice(jiro, dice, N-1, 1)

  if(N.ne.K) then
     taro(1:6) = dice(1:6)
     call cast_dice(taro, dice, (N-1)-K, 1)
     call cast_dice(taro, dice2, K,    N-K)
  else
     taro(1:6) = dice2(1:6)
     call cast_dice(taro, dice2, N-1, 1)
  end if
  total = 6**N
  taro_sum = total
  jiro_sum = 0
  do i=1,6*N
     taro_sum = taro_sum - taro(i) ! gt i
     win = win + taro_sum*jiro(i)
  end do
  print '("0",f0.15)', DBLE(win)/(DBLE(total)*DBLE(total))
contains
  subroutine printer(me)
    integer::i
    integer::me(60)
    do i=1,6*N
       print *,i,me(i)
    end do
  end subroutine printer

  subroutine cast_dice(name,dice,M,L)
    integer,intent(out)::name(60)
    integer,intent(in)::M,L,dice(6)
    integer::memo(60),i,j,k
    data memo/60*0/

    do k=1,M
       memo = 0
       do i=k,6*(k+L-1)
          do j=1,6
             memo(i+j) = memo(i+j) + name(i)*dice(j)
          end do
       end do
       name = memo
    end do
  end subroutine cast_dice
end program main
0