結果

問題 No.144 エラトステネスのざる
ユーザー tetsuzuki1115
提出日時 2017-12-01 23:31:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 658 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 78,356 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 22:48:19
合計ジャッジ時間 17,364 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    double ans = 0;
    int N;
    cin >> N;
    double p;
    cin >> p;
    
    for ( int i = 2; i <= N; i++ ) {
        
        int d = 0;
        for ( int j = 2; j*j <= i; j++ ) {
            if ( i%j == 0 ) { d += j*j == i ? 1 : 2; }
        }
        ans += pow( (1-p), d );
        
    }
    
    printf( "%f\n", ans );
    
    return 0;
}
0