結果
| 問題 | No.1022 Power Equation |
| コンテスト | |
| ユーザー |
C
|
| 提出日時 | 2026-10-22 23:12:21 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 6 ms / 2,000 ms |
| + 646µs | |
| コード長 | 1,527 bytes |
| 記録 | |
| コンパイル時間 | 6,168 ms |
| コンパイル使用メモリ | 388,492 KB |
| 実行使用メモリ | 9,872 KB |
| 最終ジャッジ日時 | 2026-10-22 23:12:47 |
| 合計ジャッジ時間 | 7,603 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pll=pair<ll,ll>;
using pi=pair<int,int>;
// using mint=modint998244353;
// using mint2=static_modint<2>;
// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;
#line 2 "math/isqrt.hpp"
#include <cmath>
using namespace std;
// floor(sqrt(n)) を返す (ただし n が負の場合は 0 を返す)
long long isqrt(long long n) {
if (n <= 0) return 0;
long long x = sqrt(n);
while ((x + 1) * (x + 1) <= n) x++;
while (x * x > n) x--;
return x;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin>>T;
while(T--){
ll N;
cin>>N;
ll ans=2*N*N-N;
ll lim=isqrt(N)+1;
vector<bool> perfect_power(lim,false);
rep(x,2,lim){
if(perfect_power[x])continue;
for(ll y=x*x;y<lim;y*=x){
perfect_power[y]=true;
}
}
vll F(30);
rep(K,1,30){
rep(p,1,K)F[K]+=(N*gcd(p,K))/K;
F[K]*=2;
F[K]+=F[K-1];
}
rep(x,2,lim){
if(perfect_power[x])continue;
ll K=1,y=x;
while(y<=N/x){
y*=x;
++K;
}
ans+=F[K];
}
cout<<ans<<'\n';
}
}
C