結果

問題 No.58 イカサマなサイコロ
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-09 03:11:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,627 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 2,901 ms
コンパイル使用メモリ 72,084 KB
実行使用メモリ 56,440 KB
最終ジャッジ日時 2023-09-13 01:39:05
合計ジャッジ時間 18,770 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 649 ms
55,940 KB
testcase_01 AC 2,627 ms
56,192 KB
testcase_02 AC 625 ms
55,716 KB
testcase_03 AC 387 ms
56,440 KB
testcase_04 AC 1,647 ms
55,600 KB
testcase_05 AC 1,955 ms
55,868 KB
testcase_06 AC 2,409 ms
56,208 KB
testcase_07 AC 633 ms
55,736 KB
testcase_08 AC 1,139 ms
55,448 KB
testcase_09 AC 2,354 ms
55,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No058{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int win = 0;
		int num_sample = 10000000;
		Random rand = new Random();
		for(int i = 0; i < num_sample; i++){
			int taro_score = 0;
			int jiro_score = 0;
			for(int n = 0; n < N; n++){
				if(n < K){
					taro_score += rand.nextInt(3)+3;
				}else taro_score += rand.nextInt(6);
				jiro_score += rand.nextInt(6);
			}
			if(taro_score > jiro_score) win++;
		}
		System.out.println((double)win/(double)num_sample);
	}
}
0