結果
| 問題 |
No.301 サイコロで確率問題 (1)
|
| コンテスト | |
| ユーザー |
taiga000629
|
| 提出日時 | 2021-02-17 16:19:44 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 807 bytes |
| コンパイル時間 | 133 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 24,768 KB |
| 最終ジャッジ日時 | 2024-09-14 03:08:51 |
| 合計ジャッジ時間 | 4,526 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 1 |
ソースコード
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))
taiga000629