結果

問題 No.144 エラトステネスのざる
ユーザー ki_ki33ki_ki33
提出日時 2015-02-06 00:00:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 1,365 bytes
コンパイル時間 2,899 ms
コンパイル使用メモリ 76,408 KB
実行使用メモリ 62,488 KB
最終ジャッジ日時 2023-09-05 13:19:29
合計ジャッジ時間 7,198 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
56,048 KB
testcase_01 AC 140 ms
55,960 KB
testcase_02 AC 141 ms
56,080 KB
testcase_03 AC 141 ms
56,196 KB
testcase_04 AC 140 ms
56,316 KB
testcase_05 AC 140 ms
56,004 KB
testcase_06 AC 139 ms
53,924 KB
testcase_07 AC 141 ms
56,048 KB
testcase_08 AC 139 ms
56,356 KB
testcase_09 AC 141 ms
56,072 KB
testcase_10 AC 142 ms
55,952 KB
testcase_11 AC 142 ms
55,576 KB
testcase_12 AC 141 ms
56,016 KB
testcase_13 AC 201 ms
62,140 KB
testcase_14 AC 192 ms
60,376 KB
testcase_15 AC 193 ms
62,488 KB
testcase_16 AC 194 ms
62,144 KB
testcase_17 AC 197 ms
61,912 KB
testcase_18 AC 198 ms
61,952 KB
testcase_19 AC 194 ms
62,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListSet;

public class Main {
	public static final int C =  1000000007;
	static final int CY = 1000000000;
	//static boolean MAP[][];
	static int K;
	static int N;
	static double P;
	static String S;
	static int M;
	static int MAX = -1;
	//static int tic[][];
	static int T[][];
	static int Y[];
	static double W[];
	//static int max;
	static long DP[];
	static int ST[][];
	//static int p[];
	//static ArrayList<HashSet<Integer>> al;
	static ConcurrentSkipListSet<Integer> TS;
	static ArrayList<Integer> AL;
	//static int a[][];
	//static char[][] ch;
	//static ArrayList<HashMap<Long, Long>> al;
	//static String a[];
	//static String str;

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



		N = sc.nextInt();
		P = 1.0 - sc.nextDouble();

		

		double ans = 0;
		
		double a[] = new double[N+1];
		Arrays.fill(a, 1.0);
		
		for (int i=2; i <= N; i++) {
			//if (a[i] == -1) continue;
			for (int t = i*2; t <= N; t += i) {
				a[t] = a[t] * P;
			}
			ans+=a[i];
			
			
		}

		
		
		System.out.println(ans);

	}


}
0