結果

問題 No.144 エラトステネスのざる
ユーザー 抹茶アイス
提出日時 2023-08-09 09:36:10
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 924 bytes
コンパイル時間 915 ms
コンパイル使用メモリ 109,892 KB
実行使用メモリ 52,140 KB
最終ジャッジ日時 2024-11-14 16:27:49
合計ジャッジ時間 23,116 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.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++)
            {
                sum += Math.Pow((1 - p), DivisorCount(i));
            }
            Console.WriteLine(sum);
        }
        public static int DivisorCount(int n)
        {
            var m = 0;
            var k = Math.Sqrt(n);
            for (var i = 2; i <= k; i++)
            {
                if (n % i == 0)
                {
                    m++;
                    if (i != k)
                    {
                        m++;
                    }
                }
            }
            return m;
        }
    }
}
0