結果

問題 No.144 エラトステネスのざる
ユーザー magurogumamaguroguma
提出日時 2017-08-22 13:44:54
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 501 bytes
コンパイル時間 2,852 ms
コンパイル使用メモリ 75,348 KB
実行使用メモリ 56,092 KB
最終ジャッジ日時 2024-04-23 04:44:10
合計ジャッジ時間 24,301 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
41,316 KB
testcase_01 AC 97 ms
53,112 KB
testcase_02 AC 96 ms
53,096 KB
testcase_03 AC 106 ms
53,972 KB
testcase_04 AC 110 ms
54,188 KB
testcase_05 AC 96 ms
53,060 KB
testcase_06 AC 116 ms
56,092 KB
testcase_07 AC 97 ms
52,984 KB
testcase_08 AC 102 ms
53,000 KB
testcase_09 AC 96 ms
53,056 KB
testcase_10 AC 94 ms
52,780 KB
testcase_11 AC 97 ms
52,760 KB
testcase_12 AC 98 ms
53,060 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class yuki144 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] strs = scanner.nextLine().split(" ", 0);
		int N = Integer.parseInt(strs[0]);
		double p = Double.parseDouble(strs[1]);

		double ans = 0.0;
		for(int i=2; i<=N; i++){
			int j = 2;
			int dNum = 0;
			while(j*j<=i){
				if(i%j==0){
					dNum += j*j!=i ? 2 : 1;
				}
				j += 1;
			}
			ans += Math.pow(1-p, dNum);
		}
		System.out.println(ans);
	}

}
0