結果

問題 No.144 エラトステネスのざる
ユーザー bachoppibachoppi
提出日時 2020-09-17 23:08:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 1,135 ms
コンパイル使用メモリ 117,932 KB
実行使用メモリ 7,696 KB
最終ジャッジ日時 2023-09-04 08:00:58
合計ジャッジ時間 3,587 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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