結果
| 問題 |
No.1022 Power Equation
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-10 22:04:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 882 bytes |
| コンパイル時間 | 3,930 ms |
| コンパイル使用メモリ | 192,952 KB |
| 最終ジャッジ日時 | 2025-01-09 16:12:44 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
lint port(lint x,lint y){
if(y==1)return x;
if(y==2)return std::sqrt(x);
if(y==3)return std::cbrt(x);
if(35<y)return 1;
lint i=1;
for(;;i++){
lint p=1;
for(lint j=0;j<y;j++)p*=i;
if(x<p)break;
}
return i-1;
}
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint t;std::cin>>t;
while(t--){
lint n;std::cin>>n;
lint ans=0;
lint lg=std::log2(n);
for(lint p=1;p<=lg;p++){
for(lint q=1;q<=lg;q++){
if(std::gcd(p,q)!=1)continue;
lint r=std::max(p,q);
ans+=(port(n,r)-1)*(n/r);
}}
ans+=n*n;
std::cout<<ans<<'\n';
}
}
ngtkana