結果
問題 |
No.1022 Power Equation
|
ユーザー |
|
提出日時 | 2020-07-23 20:06:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 985 bytes |
コンパイル時間 | 2,207 ms |
コンパイル使用メモリ | 199,996 KB |
最終ジャッジ日時 | 2025-01-12 04:25:21 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; constexpr long long N = 100000; signed main() { ios::sync_with_stdio(false); cin.tie(0); auto solve = [&] () -> long long { long long n; cin >> n; long long one = max(0LL, n - N); vector<bool> ok(N + 10, true); vector<vector<long long>> p(35, vector<long long>(35)); long long ans = n * n; for (long long x = 2; x <= min(n, N); x++) if (ok[x]) { int cnt = 0; long long y = x; while (y <= n) { cnt++; if (y <= N) ok[y] = false; else one--; y *= x; } for (int i = 1; i <= cnt; i++) for (int j = 1; j <= cnt; j++) { p[i][j]++; } } p[1][1] += one; for (int i = 1; i < 35; i++) for (int j = 1; j < 35; j++) { int g = __gcd(i, j); int k = max(i, j) / g; ans += p[i][j] * (n / k); } return ans; }; int t; cin >> t; while (t--) cout << solve() << '\n'; return 0; }