結果

問題 No.144 エラトステネスのざる
ユーザー mbanmban
提出日時 2016-12-23 19:16:01
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 101,520 KB
実行使用メモリ 29,212 KB
最終ジャッジ日時 2023-08-21 07:37:43
合計ジャッジ時間 5,532 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
28,952 KB
testcase_01 AC 103 ms
26,948 KB
testcase_02 AC 103 ms
26,920 KB
testcase_03 AC 103 ms
26,964 KB
testcase_04 AC 103 ms
28,832 KB
testcase_05 AC 101 ms
26,792 KB
testcase_06 AC 102 ms
26,964 KB
testcase_07 AC 103 ms
29,076 KB
testcase_08 AC 105 ms
27,088 KB
testcase_09 AC 104 ms
27,128 KB
testcase_10 AC 106 ms
29,036 KB
testcase_11 AC 106 ms
27,164 KB
testcase_12 AC 104 ms
24,812 KB
testcase_13 AC 143 ms
26,988 KB
testcase_14 AC 163 ms
29,044 KB
testcase_15 AC 173 ms
27,112 KB
testcase_16 AC 169 ms
27,140 KB
testcase_17 AC 167 ms
29,212 KB
testcase_18 AC 169 ms
29,132 KB
testcase_19 AC 136 ms
28,976 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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]);
    }

}

0