結果
| 問題 |
No.2829 GCD Divination
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2024-08-03 13:28:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,858 bytes |
| コンパイル時間 | 4,432 ms |
| コンパイル使用メモリ | 255,536 KB |
| 最終ジャッジ日時 | 2025-02-23 20:49:30 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 26 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
// makediv
vector<ll> makediv(ll n){
vector<ll> ld, ud;
for (ll i=1; i*i<=n; i++){
if (n%i == 0){
ld.push_back(i);
if (i != n/i){
ud.push_back(n/i);
}
}
}
reverse(ud.begin(), ud.end());
ld.insert(ld.end(), ud.begin(), ud.end());
return ld;
}
// -----
int main(){
int n; cin >> n;
vector<ll> d = makediv(n);
int m = d.size();
vector<long double> dp(m);
for (int i=1; i<m; i++){
vector<ll> cnts(i);
long double tr = 0;
for (int j=i-1; j>=0; j--){
cnts[j] = d[i] / d[j];
for (int k=j+1; k<i; k++){
if (d[k] % d[j] == 0){
cnts[j] -= cnts[k];
}
}
cnts[j] -= 1;
tr += cnts[j] * dp[j];
}
tr /= (long double)d[i];
tr += 1;
tr *= (long double)d[i] / (long double)(d[i] - 1);
dp[i] = tr;
}
cout << fixed << setprecision(15);
cout << dp[m-1] << endl;
}
shobonvip