結果

問題 No.58 イカサマなサイコロ
ユーザー rn4rurn4ru
提出日時 2016-04-14 09:00:28
言語 Java19
(openjdk 21)
結果
AC  
実行時間 1,491 ms / 5,000 ms
コード長 684 bytes
コンパイル時間 2,801 ms
コンパイル使用メモリ 72,512 KB
実行使用メモリ 56,096 KB
最終ジャッジ日時 2023-07-27 13:18:30
合計ジャッジ時間 12,941 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 429 ms
56,096 KB
testcase_01 AC 1,491 ms
55,820 KB
testcase_02 AC 411 ms
55,668 KB
testcase_03 AC 288 ms
55,776 KB
testcase_04 AC 940 ms
55,676 KB
testcase_05 AC 1,075 ms
56,032 KB
testcase_06 AC 1,315 ms
55,856 KB
testcase_07 AC 425 ms
53,780 KB
testcase_08 AC 691 ms
55,784 KB
testcase_09 AC 1,311 ms
55,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Random;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();

		Random r = new Random();
		int win = 0;
		int lose = 0;
		long iteration = 5000000L;
		for (int i = 0; i < iteration; i++) {
			int jiro = 0;
			for (int j = 0; j < N; j++) {
				jiro += r.nextInt(6) + 1;
			}
			int taro = 0;
			for (int j = 0; j < N - K; j++) {
				taro += r.nextInt(6) + 1;
			}
			for (int j = 0; j < K; j++) {
				taro += r.nextInt(3) + 4;
			}
			if (jiro < taro)
				win++;
		}

		System.out.format("%f", ((float) win) / iteration);

	}

}
0