結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2016-02-18 01:49:18 |
言語 | C++11 (gcc 13.3.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 633 bytes |
コンパイル時間 | 602 ms |
コンパイル使用メモリ | 60,852 KB |
最終ジャッジ日時 | 2024-11-14 19:34:24 |
合計ジャッジ時間 | 1,086 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:20: error: ‘pow’ was not declared in this scope 25 | ans += pow(1-p,cnt[i]); | ^~~
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <iomanip>using namespace std;#define RREP(i,s,e) for (int i = e-1; i >= s; i--)#define rrep(i,n) RREP(i,0,n)#define REP(i,s,e) for (int i = s; i < e; i++)#define rep(i,n) REP(i,0,n)int main() {int n;double p;cin >> n >> p;int cnt[n+1];double ans = 0;fill(cnt,cnt+n+1,0);REP (i,2,n+1) {for (int j = i * 2; j <= n; j += i)cnt[j]++;if (cnt[i] == 0)ans++;elseans += pow(1-p,cnt[i]);}cout << fixed << setprecision(10) << ans << endl;return 0;}