結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
pitsu_kyo_pro
|
| 提出日時 | 2019-12-21 15:29:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 2,000 ms |
| コード長 | 985 bytes |
| コンパイル時間 | 1,542 ms |
| コンパイル使用メモリ | 166,780 KB |
| 実行使用メモリ | 7,648 KB |
| 最終ジャッジ日時 | 2024-07-19 11:23:12 |
| 合計ジャッジ時間 | 2,604 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
int N;
double p;
cin >> N >> p;
double ans=0.0;
vector<int> divisor(N+1,0);
for(int i=2; i<=N; i++){
for(int j=i; j<=N; j+=i){
divisor[j]++;
}
ans += pow(1-p, divisor[i]-1);
}
cout << fixed << setprecision(10) << ans << endl;
return 0;
}
pitsu_kyo_pro