結果
問題 | No.2829 GCD Divination |
ユーザー |
|
提出日時 | 2024-08-02 22:04:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,068 bytes |
コンパイル時間 | 1,268 ms |
コンパイル使用メモリ | 99,216 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-08-02 22:04:51 |
合計ジャッジ時間 | 2,437 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 30 |
ソースコード
#include <iostream>#include <iomanip>#include <cassert>#include <map>using namespace std;using ll = long long;template<class T> inline bool chmax(T& a, const T& b) {if (a<b) {a=b; return true;} return false;}template<class T> inline bool chmin(T& a, const T& b) {if (b<a) {a=b; return true;} return false;}const int INTINF = 1000001000;const int INTMAX = 2147483647;const ll LLMAX = 9223372036854775807;const ll LLINF = 1000000000000000000;int main() {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);ll N; cin >> N;map<ll,double> memo;memo[1] = 0.0;auto solve = [&memo] (auto self, ll n) -> double {if (memo.contains(n)) return memo.at(n);double divsum = 0;for (int d=2; d*d <= n; d++) {if (n % d == 0) {divsum += self(self, d);if (d != n/d) {divsum += self(self, n/d);}}}double ret = double(n) / double(n-1) + divsum / double(n-1);memo[n] = ret;return ret;};cout << fixed << setprecision(10);cout << solve(solve,N) << endl;return 0;}