結果

問題 No.58 イカサマなサイコロ
ユーザー YamaKasa
提出日時 2018-06-26 23:47:24
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 727 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 74,396 KB
実行使用メモリ 54,508 KB
最終ジャッジ日時 2024-06-30 23:00:12
合計ジャッジ時間 32,209 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		scan.close();
		int p1;			// 普通のサイコロの和
		int p2; 		// イカサマなサイコロの和
		int n = 10000000;	// シミュレーション回数
		int win = 0;	// p2の勝利数
		for(int i = 0; i < n; i++) {
			p1 = 0;
			p2 = 0;
			for(int j = 0; j < N; j++) {
				p1 += (int)(Math.random() * 6) + 1;
				if(j < K) {
					p2 += (int)(Math.random() * 3) + 4;
				}else {
					p2 += (int)(Math.random() * 6) + 1;
				}
			}
			if(p2 > p1) {
				win ++;
			}
		}
		double ans = (double) win / n;
		System.out.println(ans);
	}
}
0