結果

問題 No.58 イカサマなサイコロ
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-06 22:12:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,720 ms / 5,000 ms
コード長 841 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 72,864 KB
実行使用メモリ 55,984 KB
最終ジャッジ日時 2023-08-18 19:39:46
合計ジャッジ時間 13,051 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 460 ms
55,676 KB
testcase_01 AC 1,720 ms
55,484 KB
testcase_02 AC 459 ms
55,788 KB
testcase_03 AC 293 ms
55,736 KB
testcase_04 AC 1,097 ms
55,932 KB
testcase_05 AC 1,256 ms
55,940 KB
testcase_06 AC 1,554 ms
55,732 KB
testcase_07 AC 456 ms
55,548 KB
testcase_08 AC 778 ms
55,984 KB
testcase_09 AC 1,556 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int c=0;
        int win=0;
        while(c<3000000){
            int taro=0;
            int jiro=0;
            for(int i=0; i<N; i++){
                int t=(int)(Math.random()*6)+1;
                taro+=t;
            }
            for(int i=0; i<N-K; i++){
                int t=(int)(Math.random()*6)+1;
                jiro+=t;
            }
            for(int i=0; i<K; i++){
                int t=(int)((Math.random()*3)+4);
                jiro+=t;
            }
            if(jiro>taro){
                win++;
            }
            c++;
        }
        double ans = (double)win/c;
        System.out.println(ans);
    }
}
0