結果

問題 No.144 エラトステネスのざる
ユーザー GrenacheGrenache
提出日時 2015-08-26 21:22:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 3,695 ms
コンパイル使用メモリ 71,944 KB
実行使用メモリ 62,456 KB
最終ジャッジ日時 2023-09-25 18:36:09
合計ジャッジ時間 8,233 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
56,044 KB
testcase_01 AC 143 ms
55,876 KB
testcase_02 AC 141 ms
55,684 KB
testcase_03 AC 144 ms
56,092 KB
testcase_04 AC 142 ms
56,032 KB
testcase_05 AC 141 ms
56,004 KB
testcase_06 AC 140 ms
56,264 KB
testcase_07 AC 141 ms
56,008 KB
testcase_08 AC 139 ms
56,296 KB
testcase_09 AC 141 ms
55,864 KB
testcase_10 AC 146 ms
55,972 KB
testcase_11 AC 144 ms
55,984 KB
testcase_12 AC 140 ms
56,168 KB
testcase_13 AC 197 ms
62,312 KB
testcase_14 AC 198 ms
62,428 KB
testcase_15 AC 197 ms
61,928 KB
testcase_16 AC 200 ms
62,252 KB
testcase_17 AC 201 ms
62,432 KB
testcase_18 AC 201 ms
62,132 KB
testcase_19 AC 201 ms
62,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;


public class Main_yukicoder144 {

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

        int n = sc.nextInt();
        double p = sc.nextDouble();

        double[] dp = new double[n];
        Arrays.fill(dp, 1.0);
        double ret = 0;
        for (int i = 2; i <= n; i++) {
        	for (int j = 2; i * j <= n; j++) {
        		dp[i * j - 1] *= (1.0 - p);
        	}
        	ret += dp[i - 1];
        }

        System.out.printf("%.7f\n", ret);
        
        sc.close();
    }
}
0