結果

問題 No.144 エラトステネスのざる
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-08-02 09:29:02
言語 C#
(.NET 8.0.203)
結果
TLE  
実行時間 -
コード長 915 bytes
コンパイル時間 18,979 ms
コンパイル使用メモリ 167,860 KB
実行使用メモリ 61,984 KB
最終ジャッジ日時 2024-04-20 08:57:09
合計ジャッジ時間 14,728 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
33,024 KB
testcase_01 AC 62 ms
36,896 KB
testcase_02 AC 64 ms
29,952 KB
testcase_03 AC 62 ms
30,072 KB
testcase_04 AC 63 ms
30,080 KB
testcase_05 AC 65 ms
29,824 KB
testcase_06 AC 63 ms
29,696 KB
testcase_07 AC 64 ms
29,696 KB
testcase_08 AC 64 ms
29,696 KB
testcase_09 AC 63 ms
30,336 KB
testcase_10 AC 65 ms
30,208 KB
testcase_11 AC 66 ms
30,080 KB
testcase_12 AC 65 ms
29,952 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (95 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.Generic;
using System.Linq;

namespace yukicoder
{
    public class Program
    {
        public static void Main()
        {
            var line = Console.ReadLine().Split(' ');
            var n = int.Parse(line[0]);
            var p = double.Parse(line[1]);
            double sum = 0;
            for(var i = 2; i <= n; i++)
            {
                var m = Math.Pow((1 - p), Divisor(i).Count());
                sum += m;
            }
            Console.WriteLine(sum);
        }
        public static IEnumerable<int> Divisor(int n)
        {
            for(var i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    yield return i;
                    if (i * i != n)
                    {
                        yield return n / i;
                    }
                }
            }
        }
    }
}
0