結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2016-01-25 02:59:15 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 869 bytes |
コンパイル時間 | 1,243 ms |
コンパイル使用メモリ | 159,620 KB |
実行使用メモリ | 7,808 KB |
最終ジャッジ日時 | 2024-09-21 16:11:34 |
合計ジャッジ時間 | 2,414 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include "bits/stdc++.h"using namespace std;typedef long long ll;typedef unsigned long long ull;typedef vector<int> veci;typedef vector<string> vecs;#define REP(i, a, n) for(ll i = a; i < n; i++)#define rep(i, n) REP(i, 0, n)template<class T> void read(T& a){cin >> a;}template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}template<class T> void write(T a){cout << a << endl;}void write(double a){cout << fixed << setprecision(12) << a << endl;}template<class T> void warr(T a, int n, char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}int main(void){int a[1000001] = {0};int n;double p;read(n);read(p);REP(i, 2, n+1) {for(int j = i*2; j <= n; j += i) {a[j]++;}}double res = 0;REP(i, 2, n+1)res += pow(1-p, a[i]);write(res);return 0;}