結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2015-02-06 00:00:41 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 223 ms / 2,000 ms |
コード長 | 1,365 bytes |
コンパイル時間 | 2,488 ms |
コンパイル使用メモリ | 81,156 KB |
実行使用メモリ | 49,700 KB |
最終ジャッジ日時 | 2024-06-23 08:57:50 |
合計ジャッジ時間 | 7,192 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
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); } }