結果

問題 No.144 エラトステネスのざる
ユーザー ShibuyapShibuyap
提出日時 2019-10-12 07:41:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,344 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 168,580 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 04:21:46
合計ジャッジ時間 18,470 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int yakusuu(int x){
    int x_ = x;
    vector<P> v;
    srep(i,2,x){
        if(x_ == 1)break;
        if(i*i>x)break;
        if(x_ % i == 0){
            int num = i;
            int cnt = 0;
            while(x_ % i == 0){
                cnt++;
                x_ /= i;
            }
            v.push_back(P(num, cnt));
        }
    }
    if(x_ > 1){
        v.push_back(P(x_, 1));
    }
    int res = 1;
    rep(i,v.size()){
        res *= v[i].second + 1;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    double p; cin >> p;
    p = 1-p;

    double ans = 0;

    srep(i,2,n+1){
        int y = yakusuu(i);
        y -= 2;
        double tmp = 1;
        rep(j,y){
            tmp *= p;
        }
        ans += tmp;
    }

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