結果
| 問題 | No.2829 GCD Divination |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-02 22:03:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,107 bytes |
| コンパイル時間 | 1,107 ms |
| コンパイル使用メモリ | 98,960 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-08-02 22:03:07 |
| 合計ジャッジ時間 | 2,673 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
int divcnt = 0;
double divsum = 0;
for (int d=2; d*d <= n; d++) {
if (n % d == 0) {
divcnt++;
divsum += self(self, d);
if (d != n/d) {
divcnt++;
divsum += self(self, n/d);
}
}
}
double ret = (n + divsum) / double(n-1);
memo[n] = ret;
return ret;
};
cout << fixed << setprecision(10);
cout << solve(solve,N) << endl;
return 0;
}