結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
![]() |
提出日時 | 2016-12-23 19:15:12 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 771 bytes |
コンパイル時間 | 835 ms |
コンパイル使用メモリ | 111,232 KB |
実行使用メモリ | 27,504 KB |
最終ジャッジ日時 | 2024-12-14 17:01:22 |
合計ジャッジ時間 | 2,231 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 RE * 7 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { const int MAX = 100000; static int N; static double p; static int[] D = new int[MAX+1]; static void Main() { for (int i = 2; i <= MAX; i++) for (int j = i + i; j <= MAX; j += i) D[j]++; string[] S = Console.ReadLine().Split(' '); N = int.Parse(S[0]); p = double.Parse(S[1]); double ans = 0; for(int i = 2; i <= N; i++) { ans += P(i); } Console.WriteLine(ans); } static double P(int i) { return Math.Pow(1.0 - p, D[i]); } }