結果
問題 | No.1022 Power Equation |
ユーザー |
![]() |
提出日時 | 2020-04-10 22:33:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 1,074 bytes |
コンパイル時間 | 773 ms |
コンパイル使用メモリ | 75,884 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 21:04:29 |
合計ジャッジ時間 | 1,434 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>#include <cstdio>#include <cstring>#include <cmath>using namespace std;using ll = long long;int gcd(int n, int m) {if (n < m) swap(n, m);while (m != 0) {int r = n % m;n = m;m = r;}return n;}int main() {int t;cin >> t;for (int _ = 0; _ < t; _++) {ll n;cin >> n;ll r = 0;int m = (int)sqrt(n);vector<int> a(m + 1, 0);for (int k = 2; k <= m; k++) {if (a[k]) continue;int c = 0;for (ll l = k; l <= n; l *= k) {if (l <= m) a[l] = 1;c++;}for (int i = 1; i <= c; i++) {for (int j = 1; j < i; j++) {int g = gcd(i, j);int i1 = i / g, j1 = j / g;r += n / i1;}}}r *= 2;r += n * n - n + n * n;cout << r << '\n';}return 0;}