結果

問題 No.58 イカサマなサイコロ
ユーザー YamaKasaYamaKasa
提出日時 2018-06-26 23:47:24
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 727 bytes
コンパイル時間 1,863 ms
コンパイル使用メモリ 71,156 KB
実行使用メモリ 56,564 KB
最終ジャッジ日時 2023-09-13 14:15:31
合計ジャッジ時間 32,164 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,183 ms
55,872 KB
testcase_01 TLE -
testcase_02 AC 1,154 ms
55,528 KB
testcase_03 AC 660 ms
56,532 KB
testcase_04 AC 3,184 ms
55,840 KB
testcase_05 AC 3,746 ms
55,916 KB
testcase_06 AC 4,794 ms
53,628 KB
testcase_07 AC 1,180 ms
56,208 KB
testcase_08 AC 2,206 ms
55,944 KB
testcase_09 AC 4,745 ms
56,176 KB
権限があれば一括ダウンロードができます

ソースコード

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