結果

問題 No.58 イカサマなサイコロ
ユーザー GrenacheGrenache
提出日時 2015-11-03 20:35:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,742 ms / 5,000 ms
コード長 686 bytes
コンパイル時間 3,760 ms
コンパイル使用メモリ 72,544 KB
実行使用メモリ 56,320 KB
最終ジャッジ日時 2023-10-11 13:29:42
合計ジャッジ時間 20,141 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 668 ms
55,820 KB
testcase_01 AC 2,742 ms
56,320 KB
testcase_02 AC 660 ms
55,976 KB
testcase_03 AC 401 ms
56,184 KB
testcase_04 AC 1,712 ms
56,284 KB
testcase_05 AC 1,949 ms
56,032 KB
testcase_06 AC 2,492 ms
56,100 KB
testcase_07 AC 672 ms
56,020 KB
testcase_08 AC 1,179 ms
55,764 KB
testcase_09 AC 2,456 ms
55,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder58 {

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        int win = 0;
        int m = 5000000;
        for (int i = 0; i < m; i++) {
        	if (sum(n, k) > sum(n, 0)) {
        		win++;
        	}
        }

		System.out.printf("%.4f\n", (double)win / m);
        
        sc.close();
    }

	private static int sum(int n, int k) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (i < k) {
				sum += (int)(Math.random() * 3) + 4;
			} else {
				sum += (int)(Math.random() * 6) + 1;
			}
		}
		
		return sum;
	}
}
0