結果

問題 No.144 エラトステネスのざる
ユーザー masayamatumasayamatu
提出日時 2022-06-18 15:30:02
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,327 bytes
コンパイル時間 7,323 ms
コンパイル使用メモリ 167,604 KB
実行使用メモリ 190,188 KB
最終ジャッジ日時 2024-04-18 11:50:15
合計ジャッジ時間 9,987 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
30,080 KB
testcase_01 AC 63 ms
30,592 KB
testcase_02 AC 61 ms
30,080 KB
testcase_03 AC 61 ms
30,080 KB
testcase_04 AC 58 ms
30,336 KB
testcase_05 AC 64 ms
30,720 KB
testcase_06 AC 61 ms
30,592 KB
testcase_07 AC 63 ms
30,592 KB
testcase_08 AC 63 ms
30,336 KB
testcase_09 AC 59 ms
30,464 KB
testcase_10 AC 62 ms
30,336 KB
testcase_11 AC 61 ms
30,592 KB
testcase_12 AC 65 ms
30,208 KB
testcase_13 AC 100 ms
34,688 KB
testcase_14 AC 97 ms
34,744 KB
testcase_15 AC 98 ms
34,748 KB
testcase_16 AC 98 ms
34,876 KB
testcase_17 AC 99 ms
34,816 KB
testcase_18 AC 102 ms
34,944 KB
testcase_19 AC 93 ms
190,188 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (86 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
//using static CompLib.CompLib;
//using DataStructure;

namespace atcoder
{

    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
            var NP = Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            int N = (int)NP[0];
            double P = NP[1];
            double ans = 0;
            var prime = new bool[N + 1];
            var pow = new double[10000];
            var cnt = new int[N + 1];
            pow[1] = (1 - P);
            for (int i = 2; i < 10000; i++)
            {
                pow[i] = pow[i - 1] * (1 - P);
            }
            for (int i = 2; i <= N; i++)
            {
                int idx = 2;
                if (cnt[i] == 0) ans++;
                while (i * idx <= N)
                {
                    cnt[i * idx]++;
                    idx++;
                }
            }
            for (int i = 2; i <= N; i++)
            {
                if (cnt[i] > 0)
                {
                    ans += pow[cnt[i]];
                }

            }
            Console.WriteLine(ans);
        }
    }
}
0