結果
| 問題 |
No.144 エラトステネスのざる
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-18 02:53:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 476 bytes |
| コンパイル時間 | 2,354 ms |
| コンパイル使用メモリ | 197,808 KB |
| 最終ジャッジ日時 | 2025-01-09 21:05:42 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | double p; scanf("%d%lf",&n,&p);
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
vector<long long> divisors(long long a){
vector<long long> res;
for(long long i=1;i*i<=a;i++) if(a%i==0) {
res.emplace_back(i);
if(i*i<a) res.emplace_back(a/i);
}
sort(res.begin(),res.end());
return res;
}
int main(){
int n;
double p; scanf("%d%lf",&n,&p);
double ans=0;
for(int i=2;i<=n;i++){
ans+=pow(1-p,divisors(i).size()-2);
}
printf("%.9f\n",ans);
return 0;
}