結果

問題 No.1022 Power Equation
ユーザー trineutrontrineutron
提出日時 2020-04-10 22:19:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 2,463 ms
コンパイル使用メモリ 198,396 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 01:02:29
合計ジャッジ時間 2,869 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 22 ms
4,352 KB
testcase_05 AC 30 ms
4,348 KB
testcase_06 AC 29 ms
4,348 KB
testcase_07 AC 29 ms
4,348 KB
testcase_08 AC 16 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
}
0