結果
| 問題 |
No.58 イカサマなサイコロ
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-08-25 00:34:20 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,275 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 32,496 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 02:11:47 |
| 合計ジャッジ時間 | 755 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
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
jj