結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2016-12-23 19:16:01 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 772 bytes |
| コンパイル時間 | 907 ms |
| コンパイル使用メモリ | 114,360 KB |
| 実行使用メモリ | 30,980 KB |
| 最終ジャッジ日時 | 2024-12-14 17:01:35 |
| 合計ジャッジ時間 | 3,325 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
コンパイルメッセージ
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 = 1000000;
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]);
}
}
mban