結果
| 問題 |
No.1022 Power Equation
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2020-04-10 21:38:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 748 bytes |
| コンパイル時間 | 626 ms |
| コンパイル使用メモリ | 69,504 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 19:33:16 |
| 合計ジャッジ時間 | 1,158 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// Exactly same as TopCoder SRM 713 Div1 Easy - PowerEquation
int gcd(int x, int y) {
if (y == 0) return x;
return gcd(y, x % y);
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int Q;
cin >> Q;
while (Q--) {
int n;
cin >> n;
long long ret = 1LL * (2 * n - 1) * n;
for (int i = 1; i <= 32; i++) {
for (int j = 1; j <= 32; j++) {
if (i + j == 2 || gcd(i, j) != 1) continue;
int sum = 0, p = max(i, j);
for (int k = 2; ; k++) {
long long prod = 1;
for (int l = 0; l < p; l++) prod *= k;
if (prod > n) break;
sum++;
}
ret = (ret + 1LL * sum * (n / p));
}
}
cout << ret << endl;
}
return 0;
}
square1001