結果
問題 | No.1022 Power Equation |
ユーザー |
![]() |
提出日時 | 2020-04-10 22:19:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 592 bytes |
コンパイル時間 | 3,207 ms |
コンパイル使用メモリ | 191,608 KB |
最終ジャッジ日時 | 2025-01-09 16:16:54 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int64_t n, ans = 0; cin >> n; ans = n * n + n * (n - 1); for (int a = 2; a * a <= n; a++) { int64_t c = a * a, k = 2; while (c <= n) { for (int64_t j = 1; j < k; j++) { if (gcd(j, k) == 1) { ans += 2 * (n / k); } } k++; c *= a; } } cout << ans << endl; } }