結果

問題 No.58 イカサマなサイコロ
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-09 03:11:59
言語 Java
(openjdk 23)
結果
AC  
実行時間 2,747 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 3,466 ms
コンパイル使用メモリ 74,924 KB
実行使用メモリ 54,376 KB
最終ジャッジ日時 2024-06-30 12:22:53
合計ジャッジ時間 19,640 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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