結果
問題 | No.1022 Power Equation |
ユーザー | どらら |
提出日時 | 2020-04-11 13:57:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 1,056 bytes |
コンパイル時間 | 1,334 ms |
コンパイル使用メモリ | 167,776 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 00:04:37 |
合計ジャッジ時間 | 1,925 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; ll gcd(ll a, ll b){return (b==0?a:gcd(b,a%b));} ll solve(ll N){ ll ret = 0; ret += N*N; ret += (N*N-N); { ll sum = 0; for(ll a=2; a<=sqrt(N); a++){ ll p = a*a; for(ll b=2; p<=N; b++){ ll y = N/b; sum += y; p *= a; } } ret += 2*sum; } { ll sum = 0; for(ll b=2; b<min(N,33LL); b++){ for(ll d=b+1; d<min(N,33LL); d++){ if(gcd(b,d)==1){ for(ll a=2;;a++){ ll p = 1; rep(i,d) p *= a; if(p>N) break; sum += N/d; } } } } ret += 2*sum; } return ret; } int main(){ int T; cin >> T; while(T--){ ll N; cin >> N; cout << solve(N) << endl; } return 0; }