結果
| 問題 | No.2829 GCD Divination |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-02 22:14:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 906 bytes |
| 記録 | |
| コンパイル時間 | 2,379 ms |
| コンパイル使用メモリ | 205,256 KB |
| 最終ジャッジ日時 | 2025-02-23 20:05:35 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
map<int,double,greater<>> P;
double answer = 0;
P[N] = 1;
for(auto [i,p] : P){
if(i == 1) break;
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;
for(int k=0; k<n-1; k++){
int d = Ds.at(i).at(k);
P[d] += p*C.at(k)/(N-C.at(n-1));
}
}
cout << fixed << setprecision(20) << answer << endl;
}