結果

問題 No.144 エラトステネスのざる
ユーザー maine_honzukimaine_honzuki
提出日時 2020-05-21 13:54:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 165,440 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 23:22:19
合計ジャッジ時間 17,486 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 2 ms
6,940 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
In lambda function,
    inlined from 'int main()' at main.cpp:23:30:
main.cpp:13:20: warning: 'ret' may be used uninitialized [-Wmaybe-uninitialized]
   13 |                 ret++;
      |                 ~~~^~
main.cpp: In function 'int main()':
main.cpp:10:13: note: 'ret' was declared here
   10 |         int ret;
      |             ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    double p;
    cin >> N >> p;

    auto div = [](int n) {
        int ret;
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                ret++;
                if (i * i != n)
                    ret++;
            }
        }
        return ret;
    };

    double ans = 0;
    for (int i = 2; i <= N; i++) {
        ans += pow(1 - p, div(i) - 2);
    }

    cout << fixed << setprecision(10) << ans << endl;
}
0