結果

問題 No.144 エラトステネスのざる
ユーザー masayamatumasayamatu
提出日時 2022-06-18 14:46:16
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,244 bytes
コンパイル時間 9,437 ms
コンパイル使用メモリ 172,044 KB
実行使用メモリ 200,440 KB
最終ジャッジ日時 2024-04-18 10:41:51
合計ジャッジ時間 13,563 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 62 ms
30,208 KB
testcase_03 AC 63 ms
30,464 KB
testcase_04 AC 63 ms
30,464 KB
testcase_05 AC 62 ms
30,336 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 63 ms
30,336 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (87 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 = N - 1;
            var prime = new bool[N + 1];
            var pow = new double[100];
            var cnt = new int[N + 1];
            pow[1] = P;
            for (int i = 2; i < 100; i++)
            {
                pow[i] = pow[i - 1] * P;
            }
            for (int i = 2; i <= N; i++)
            {
                int idx = 2;
                while (i * idx <= N)
                {
                    cnt[i * idx]++;
                    idx++;
                }
            }
            for (int i = 2; i <= N; i++)
            {
                if (cnt[i] > 0)
                    ans -= (1 - pow[cnt[i]]);
            }
            Console.WriteLine(ans);
        }
    }
}
0