結果

問題 No.144 エラトステネスのざる
ユーザー BantakoBantako
提出日時 2018-05-28 10:23:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 1,404 ms
コンパイル使用メモリ 164,592 KB
実行使用メモリ 8,020 KB
最終ジャッジ日時 2023-09-12 19:57:11
合計ジャッジ時間 3,123 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
7,764 KB
testcase_01 AC 28 ms
7,672 KB
testcase_02 AC 28 ms
7,548 KB
testcase_03 AC 27 ms
7,768 KB
testcase_04 AC 27 ms
7,528 KB
testcase_05 AC 27 ms
7,580 KB
testcase_06 AC 28 ms
7,800 KB
testcase_07 AC 28 ms
7,956 KB
testcase_08 AC 28 ms
7,760 KB
testcase_09 AC 28 ms
7,800 KB
testcase_10 AC 28 ms
7,912 KB
testcase_11 AC 28 ms
7,968 KB
testcase_12 AC 28 ms
7,772 KB
testcase_13 AC 55 ms
7,796 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:21:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   21 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
/*
template<size_t max_N>
struct P{
    int count[max_N];
    //size_t counter = 0;
    constexpr P() : count() {
        for(int i = 2; i <= max_N; ++i){
            for(int j = i; j <= max_N; j += i){
                count[j]++;
            }
        }
    }
};
*/
int cnt[1000010];
main(){
    //constexpr auto c = P<10010>();
    
    for(int i = 2;i <= 100000;i++){
        for(int j = i;j <= 1000000;j += i){
            cnt[j]++;
        }
    }
    int N;
    double p;
    cin >> N >> p;

    double ans = 0;
    for(int i = 2;i <= N;i++){
        //if(cnt[i] == 1)ans += 1;
        //else 
        ans += pow(1 - p, cnt[i] - 1);
    }
    printf("%.9lf\n" ,ans);
}
0