結果
| 問題 |
No.1022 Power Equation
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-04-10 22:00:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 938 bytes |
| コンパイル時間 | 2,763 ms |
| コンパイル使用メモリ | 194,436 KB |
| 最終ジャッジ日時 | 2025-01-09 16:10:58 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int tt;
cin >> tt;
while (tt--) {
long long n;
cin >> n;
long long m = 1;
while ((m + 1) * (m + 1) <= n) {
++m;
}
long long res = n * n, cnt = n - m;
vector<bool> b(m + 1);
for (long long k = 2; k <= m; ++k) {
if (b[k]) {
continue;
}
DEBUG(k);
long long l = 0;
for (auto i = k; i <= n; i *= k) {
if (i <= m) {
b[i] = true;
} else {
--cnt;
}
++l;
}
for (int j = 1; j <= l; ++j) {
for (int i = 1; i <= j; ++i) {
if (i == j) {
res += n;
} else {
res += 2 * (n / (j / gcd(i, j)));
}
}
}
}
res += cnt * n;
cout << res << '\n';
}
}
risujiroh