結果

問題 No.144 エラトステネスのざる
ユーザー bachoppibachoppi
提出日時 2020-09-17 23:08:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 1,005 ms
コンパイル使用メモリ 115,048 KB
最終ジャッジ日時 2025-01-14 15:43:02
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 3 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



int main(){
  int n; long double p; cin >> n >> p; 
  int cnt[1010100] = {};
  for(int i=2; i<=1010000; i++){
    for(int j=2*i; j<=1010000; j+=i){
      cnt[j]++;
    }
  }
  long double ans = 0.0;
  long double pow[21];
  pow[0] = 1.0;
  rep(i, 20){
    pow[i+1] = pow[i]*p;
  }
  for(int i=2; i<=n; i++){
    ans+=pow[cnt[i]];
  }
  cout << fixed << setprecision(7) << ans << endl;
}
  
  
0