結果

問題 No.301 サイコロで確率問題 (1)
ユーザー taiga000629taiga000629
提出日時 2021-02-17 16:19:15
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 807 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 91,876 KB
最終ジャッジ日時 2023-10-12 03:25:41
合計ジャッジ時間 5,539 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

t=int(input())
from copy import deepcopy
a=[[1/6,1/6,1/6,1/6,1/6,1/6],
   [1,0,0,0,0,0],
   [0,1,0,0,0,0],
   [0,0,1,0,0,0],
   [0,0,0,1,0,0],
   [0,0,0,0,1,0]]

b=[[1/6,1/6,1/6,1/6,1/6,1/6,1],
   [1,0,0,0,0,0,0],
   [0,1,0,0,0,0,0],
   [0,0,1,0,0,0,0],
   [0,0,0,1,0,0,0],
   [0,0,0,0,1,0,0],
   [0,0,0,0,0,0,1]]

def mat(x,y):
    n=len(x)
    new=[[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                new[i][j]+=x[i][k]*y[k][j]
    return new

def mul (x,n):
    if n==1:return x
    res=mul(x,n//2)
    res=mat(res,res)
    if n%2==0:
        return res
    return mat(res,x)

for _ in range(t):
    n=int(input())
    an=mul(a,n)
    A=an[0][5]+an[0][1]+an[0][2]+an[0][3]+an[0][4]
    bn=mul(b,n)
    B=bn[0][6]

    print(B/(1-A))

0