結果

問題 No.301 サイコロで確率問題 (1)
ユーザー taiga000629taiga000629
提出日時 2021-02-17 16:16:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 828 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 17,208 KB
最終ジャッジ日時 2023-10-12 03:22:31
合計ジャッジ時間 4,813 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
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=deepcopy(mul(x,n//2))
    res=deepcopy(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