結果

問題 No.58 イカサマなサイコロ
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-16 09:29:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 503 ms / 5,000 ms
コード長 629 bytes
コンパイル時間 3,209 ms
コンパイル使用メモリ 78,996 KB
実行使用メモリ 61,076 KB
最終ジャッジ日時 2024-04-08 13:24:24
合計ジャッジ時間 7,866 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 291 ms
60,940 KB
testcase_01 AC 503 ms
60,616 KB
testcase_02 AC 294 ms
61,076 KB
testcase_03 AC 249 ms
60,504 KB
testcase_04 AC 409 ms
58,804 KB
testcase_05 AC 431 ms
60,764 KB
testcase_06 AC 482 ms
60,816 KB
testcase_07 AC 287 ms
60,776 KB
testcase_08 AC 346 ms
60,656 KB
testcase_09 AC 481 ms
59,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    double win = 0;
    for(int i = 0; i < 1000000; i++) {
      int p1 = 0;
      int p2 = 0;
      Random rnd = new Random();
      for(int j = 0; j < N; j++) {
        p1 += (rnd.nextInt(6) + 1);
      }
      for(int j = 0; j < K; j++) {
        p2 += (rnd.nextInt(3) + 4);
      }
      for(int j = 0; j < N - K; j++) {
        p2 += (rnd.nextInt(6) + 1);
      }
      if(p2 > p1) win++;
    }
    System.out.println(win / (double)1000000);
  }
}
0