結果

問題 No.58 イカサマなサイコロ
ユーザー rn4rurn4ru
提出日時 2016-04-14 09:00:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,441 ms / 5,000 ms
コード長 684 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 74,876 KB
実行使用メモリ 54,460 KB
最終ジャッジ日時 2024-04-15 01:19:10
合計ジャッジ時間 11,305 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 417 ms
54,380 KB
testcase_01 AC 1,441 ms
54,284 KB
testcase_02 AC 408 ms
54,200 KB
testcase_03 AC 281 ms
54,360 KB
testcase_04 AC 933 ms
54,308 KB
testcase_05 AC 1,050 ms
54,460 KB
testcase_06 AC 1,289 ms
54,352 KB
testcase_07 AC 409 ms
54,320 KB
testcase_08 AC 663 ms
54,068 KB
testcase_09 AC 1,286 ms
54,356 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