結果

問題 No.58 イカサマなサイコロ
ユーザー jjjj
提出日時 2016-08-25 00:26:13
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 1,253 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 32,512 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 15:11:21
合計ジャッジ時間 854 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,944 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)

  if(N.ne.K) then
     taro(1:6) = dice(1:6)
     call cast_dice(taro, dice, (N-1)-K)
     call cast_dice(taro, dice2, K)
  else
     taro(1:6) = dice2(1:6)
     call cast_dice(taro, dice2, N-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)
    integer,intent(out)::name(60)
    integer,intent(in)::M,dice(6)
    integer::memo(60),i,j,k
    data memo/60*0/

    do k=1,M
       memo = 0
       do i=k,6*(k+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