結果
問題 | No.58 イカサマなサイコロ |
ユーザー | scache |
提出日時 | 2014-12-02 04:32:01 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 123 ms / 5,000 ms |
コード長 | 1,190 bytes |
コンパイル時間 | 3,216 ms |
コンパイル使用メモリ | 74,640 KB |
実行使用メモリ | 56,380 KB |
最終ジャッジ日時 | 2023-09-02 01:00:58 |
合計ジャッジ時間 | 5,829 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 120 ms
56,340 KB |
testcase_01 | AC | 121 ms
53,748 KB |
testcase_02 | AC | 123 ms
55,500 KB |
testcase_03 | AC | 122 ms
55,944 KB |
testcase_04 | AC | 123 ms
56,380 KB |
testcase_05 | AC | 123 ms
55,756 KB |
testcase_06 | AC | 121 ms
55,504 KB |
testcase_07 | AC | 120 ms
55,752 KB |
testcase_08 | AC | 120 ms
55,796 KB |
testcase_09 | AC | 119 ms
54,424 KB |
ソースコード
import java.util.Arrays; import java.util.Scanner; public class Main58 { public static void main(String[] args) { Main58 p = new Main58(); } public Main58() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); solve(n, k); } public void solve(int n, int K) { int[][] tdp = new int[n+1][n*6+1]; int[][] jdp = new int[n+1][n*6+1]; tdp[0][0] = 1; jdp[0][0] = 1; for(int i=0;i<n;i++){ for(int j=0;j<6;j++){ int s = tdp[i].length - 1 - (i<K ? (j/2+4) : (j+1)); for(int k=s;k>=0;k--){ if(i<K) tdp[i+1][j/2+4+k] += tdp[i][k]; else tdp[i+1][j+1+k] += tdp[i][k]; } for(int k=s;k>=0;k--) jdp[i+1][j+1+k] += jdp[i][k]; } } // System.out.println(Arrays.toString(tdp[n])); // System.out.println(Arrays.toString(jdp[n])); long jsum = 0; long count = 0; for(int i=1;i<tdp[n].length;i++){ jsum += jdp[n][i-1]; if(tdp[n][i] == 0) continue; count += tdp[n][i]*jsum; } long total = 1; for(int i=0;i<n;i++) total *= 6; System.out.println((double)count/(total*total)); } }