結果
問題 |
No.58 イカサマなサイコロ
|
ユーザー |
![]() |
提出日時 | 2018-06-26 23:47:57 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 668 ms / 5,000 ms |
コード長 | 726 bytes |
コンパイル時間 | 2,287 ms |
コンパイル使用メモリ | 74,852 KB |
実行使用メモリ | 54,544 KB |
最終ジャッジ日時 | 2024-06-30 23:00:35 |
合計ジャッジ時間 | 7,192 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
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 = 1000000; // シミュレーション回数 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); } }