結果

問題 No.58 イカサマなサイコロ
ユーザー holegumaholeguma
提出日時 2015-08-12 02:52:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 115 ms / 5,000 ms
コード長 967 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 74,364 KB
実行使用メモリ 56,008 KB
最終ジャッジ日時 2023-09-25 08:20:11
合計ジャッジ時間 3,942 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,748 KB
testcase_01 AC 114 ms
55,488 KB
testcase_02 AC 114 ms
56,008 KB
testcase_03 AC 114 ms
55,940 KB
testcase_04 AC 113 ms
55,824 KB
testcase_05 AC 114 ms
55,824 KB
testcase_06 AC 114 ms
55,900 KB
testcase_07 AC 112 ms
55,624 KB
testcase_08 AC 115 ms
55,920 KB
testcase_09 AC 114 ms
55,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int t=Integer.parseInt(br.readLine());
double[][] dp1=new double[61][n+1];
double[][] dp2=new double[61][n+1];
dp1[0][0]=1;
dp2[0][0]=1;
for(int i=0;i<n;i++){
for(int j=0;j<=54;j++){
for(int k=1;k<=6;k++){
dp1[j+k][i+1]+=dp1[j][i]/6;
}
}
}
for(int i=0;i<t;i++){
for(int j=0;j<=54;j++){
for(int k=4;k<=6;k++){
dp2[j+k][i+1]+=dp2[j][i]/3;
}
}
}
for(int i=t;i<n;i++){
for(int j=0;j<=54;j++){
for(int k=1;k<=6;k++){
dp2[j+k][i+1]+=dp2[j][i]/6;
}
}
}
double ans=0;
for(int i=0;i<60;i++){
for(int j=i+1;j<=60;j++){
ans+=dp1[i][n]*dp2[j][n];
}
}
out.printf("%.20f\r\n", ans);
out.flush();
}
}
}
0