結果
| 問題 |
No.2829 GCD Divination
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-02 22:12:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 915 bytes |
| コンパイル時間 | 3,336 ms |
| コンパイル使用メモリ | 199,196 KB |
| 最終ジャッジ日時 | 2025-02-23 20:04:58 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 MLE * 1 -- * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<vector<int>> Ds(N+1);
for(int i=1; i<=N; i++) for(int k=i; k<=N; k+=i) Ds.at(k).push_back(i);
vector<double> P(N+1);
double answer = 0;
P.at(N) = 1;
for(int i=N; i>1; i--) if(P.at(i) > 1e-10){
int n = Ds.at(i).size();
vector<int> C(n);
for(int k=n-1; k>=0; k--){
int d = Ds.at(i).at(k);
int now = N/d;
for(int l=k+1; l<n; l++) if(Ds.at(i).at(l)%d == 0) now -= C.at(l);
C.at(k) = now;
}
double multi = N/(0.0+N-C.at(n-1));
answer += multi*P.at(i);
for(int k=0; k<n-1; k++){
int d = Ds.at(i).at(k);
P.at(d) += P.at(i)*C.at(k)/(N-C.at(n-1));
}
}
cout << fixed << setprecision(20) << answer << endl;
}