結果

問題 No.1022 Power Equation
ユーザー cn_449cn_449
提出日時 2020-04-10 22:06:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,656 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 100,792 KB
実行使用メモリ 8,700 KB
最終ジャッジ日時 2023-10-14 00:39:52
合計ジャッジ時間 4,489 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
//#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int t;
	cin >> t;
	vector<bool> ok(40000);
	vector<int> use;
	for (int i = 2; i < 40000; i++) {
		if (!ok[i]) {
			use.pb(i);
			int st = i;
			while (st*i < 40000) {
				st *= i;
				ok[st] = true;
			}
		}
	}
	rep (_, t) {
		int n;
		cin >> n;
		ll ans = 2 * n * n - n;
		for (int i : use) {
			if (i > n) break;
			int cnt = 0; int ch = 1;
			while (ch * i <= n) {
				cnt++; ch *= i;
		    }
			for (int j = 1; j <= cnt; j++) {
				for (int k = 1; k <= cnt; k++) {
					if (j == k) continue;
					ans += n / (max(j, k) / gcd(j, k));
				}
			}
		}
		cout << ans << endl;
	}
}
0