結果

問題 No.211 素数サイコロと合成数サイコロ (1)
ユーザー tsunabittsunabit
提出日時 2018-05-13 02:44:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 1,304 bytes
コンパイル時間 3,280 ms
コンパイル使用メモリ 71,636 KB
実行使用メモリ 56,072 KB
最終ジャッジ日時 2023-09-10 18:40:59
合計ジャッジ時間 8,886 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,728 KB
testcase_01 AC 127 ms
55,996 KB
testcase_02 AC 124 ms
55,788 KB
testcase_03 AC 125 ms
55,792 KB
testcase_04 AC 125 ms
55,772 KB
testcase_05 AC 126 ms
55,576 KB
testcase_06 AC 125 ms
55,424 KB
testcase_07 AC 126 ms
55,916 KB
testcase_08 AC 127 ms
55,936 KB
testcase_09 AC 128 ms
55,788 KB
testcase_10 AC 126 ms
55,788 KB
testcase_11 AC 128 ms
55,876 KB
testcase_12 AC 127 ms
56,008 KB
testcase_13 AC 126 ms
55,912 KB
testcase_14 AC 125 ms
55,864 KB
testcase_15 AC 125 ms
56,016 KB
testcase_16 AC 125 ms
55,836 KB
testcase_17 AC 124 ms
55,740 KB
testcase_18 AC 126 ms
56,056 KB
testcase_19 AC 128 ms
55,712 KB
testcase_20 AC 127 ms
55,880 KB
testcase_21 AC 128 ms
55,792 KB
testcase_22 AC 128 ms
55,424 KB
testcase_23 AC 125 ms
55,940 KB
testcase_24 AC 134 ms
56,044 KB
testcase_25 AC 128 ms
55,688 KB
testcase_26 AC 127 ms
55,796 KB
testcase_27 AC 128 ms
55,436 KB
testcase_28 AC 127 ms
55,700 KB
testcase_29 AC 128 ms
55,680 KB
testcase_30 AC 126 ms
55,876 KB
testcase_31 AC 126 ms
55,924 KB
testcase_32 AC 128 ms
56,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

// ***問題文***
// 素数サイコロとはそれぞれの面に 2,3,5,7,11,13 の整数が書かれているサイコロである。
// 合成数サイコロとはそれぞれの面に 4,6,8,9,10,12 の整数が書かれているサイコロである。
// 素数サイコロと合成数サイコロを 1 つずつ振った時、出目の積が K となる確率を求めるプログラムを書いてください。
// 各面が出る確率はすべて 1/6 で、それぞれのサイコロについて出る面は独立です。
// ***入力***
// K
// 0≤K≤200:整数
// ***出力***
// 答えを出力してください。 絶対誤差で 10−12 までの誤差は許容されます。

public class No211 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int[] s = {2,3,5,7,11,13};
        int[] g = {4,6,8,9,10,12};
        int count = 0;
        for(int i = 0; i < s.length; i++) {
            for(int j = 0; j < g.length; j++) {
                if(s[i] * g[j] == k) {
                    count++;
                }
            }
        }
        System.out.println((1.0 / 36.0) * count);
    }
}
0