結果
| 問題 |
No.2829 GCD Divination
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-02 22:22:26 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 644 bytes |
| コンパイル時間 | 1,274 ms |
| コンパイル使用メモリ | 109,444 KB |
| 実行使用メモリ | 86,656 KB |
| 最終ジャッジ日時 | 2024-08-02 22:22:33 |
| 合計ジャッジ時間 | 6,363 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
int gcd (int x, int y) {
while (0 < x) {
int t = x;
x = y % x;
y = t;
}
return y;
}
int main () {
int N; cin >> N;
vector<double> memo(N + 1, -1);
auto E = [&] (auto self, int x) -> double {
if (memo[x] != -1) return memo[x];
if (x == 1) return 0;
double res = 1;
for (int v = 1; v < x; v++) {
res += 1 + self(self, gcd(v, x));
}
return memo[x] = res / (x - 1);
};
cout << setprecision(10);
cout << E(E, N) << "\n";
}