結果
問題 | No.1666 累乗数 |
ユーザー |
![]() |
提出日時 | 2021-09-04 15:13:47 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,181 bytes |
コンパイル時間 | 3,942 ms |
コンパイル使用メモリ | 229,796 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-18 01:57:25 |
合計ジャッジ時間 | 35,816 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll=long long; using Graph=vector<vector<pair<int,int>>>; #define MAX 100000 #define MOD 1000000007 #define INF 1000000000000000000 ll my_pow(ll x,int n){ ll ret=1; while(n>0){ if((n&1)==1){ ret=ret*x; } n>>=1; x=x*x; } return ret; } //x以下の累乗数の個数 ll counting(ll x){ if(x==0){ return 0; } ll ans=1; for(int b=2;b<=60;b++){ ll left=0; ll right=1000000001; while(left+1<right){ ll c=(left+right)/2; if(pow((ll)c,b)>=2e18){ right=c; continue; } if(my_pow(c,b)<=x){ left=c; }else{ right=c; } } int cnt=0; for(int i=2;i<=b;i++){ if(b%i==0){ cnt++; } } if(cnt==1){ ans+=left-1; } } return ans; } void solve(){ ll K; cin>>K; ll left=0; ll right=1000000000000000001; while(left+1<right){ ll c=(left+right)/2; if(counting(c)<K){ left=c; }else{ right=c; } } cout<<right<<'\n'; } int main(){ int T; cin>>T; for(int i=0;i<T;i++){ solve(); } }