結果
問題 | No.58 イカサマなサイコロ |
ユーザー | YamaKasa |
提出日時 | 2018-06-26 23:46:00 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 725 bytes |
コンパイル時間 | 2,114 ms |
コンパイル使用メモリ | 71,172 KB |
実行使用メモリ | 58,136 KB |
最終ジャッジ日時 | 2023-09-13 14:14:47 |
合計ジャッジ時間 | 4,868 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 151 ms
56,024 KB |
testcase_01 | WA | - |
testcase_02 | AC | 147 ms
55,524 KB |
testcase_03 | AC | 155 ms
55,948 KB |
testcase_04 | AC | 173 ms
55,816 KB |
testcase_05 | AC | 180 ms
55,680 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 163 ms
55,708 KB |
testcase_09 | AC | 179 ms
55,896 KB |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int K = scan.nextInt(); scan.close(); int p1; // 普通のサイコロの和 int p2; // イカサマなサイコロの和 int n = 100000; // シミュレーション回数 int win = 0; // p2の勝利数 for(int i = 0; i < n; i++) { p1 = 0; p2 = 0; for(int j = 0; j < N; j++) { p1 += (int)(Math.random() * 6) + 1; if(j < K) { p2 += (int)(Math.random() * 3) + 4; }else { p2 += (int)(Math.random() * 6) + 1; } } if(p2 > p1) { win ++; } } double ans = (double) win / n; System.out.println(ans); } }