結果
| 問題 |
No.1666 累乗数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-03 22:00:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,078 bytes |
| コンパイル時間 | 953 ms |
| コンパイル使用メモリ | 77,060 KB |
| 実行使用メモリ | 13,316 KB |
| 最終ジャッジ日時 | 2024-12-15 13:16:24 |
| 合計ジャッジ時間 | 3,866 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 19 |
コンパイルメッセージ
main.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
38 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long sq(long N,long k)
{
if(k>=30)return 1;
long L=0,R=N+1;
while(R-L>1)
{
long mid=(L+R)/2;
long t=1;
bool ok=true;
for(int i=0;i<k;i++)
{
if(t>N/mid)
{
ok=false;
break;
}
t*=mid;
}
if(ok)L=mid;
else R=mid;
}
return L;
}
vector<long>S;
long cnt(long N)
{
long ans=0;
ans+=upper_bound(S.begin(),S.end(),N)-S.begin();
long now=sq(N,2);
ans+=now;
ans-=sq(now,2)-1;
return ans;
}
main()
{
const long LIM=1e18;
for(long k=3;;k++)
{
bool ch=false;
for(long a=2;;a++)
{
long b=1;
bool ok=true;
for(int i=0;i<k;i++)
{
if(b>LIM/a)
{
ok=false;
break;
}
b*=a;
}
if(!ok)break;
S.push_back(b);
ch=true;
}
if(!ch)break;
}
sort(S.begin(),S.end());
S.erase(unique(S.begin(),S.end()),S.end());
int T;
//cout<<cnt(4)<<endl;
//return 0;
cin>>T;
for(;T--;)
{
long K;cin>>K;
long L=0,R=1e18;
while(R-L>1)
{
long mid=(L+R)/2;
if(cnt(mid)<K)L=mid;
else R=mid;
}
cout<<R<<endl;
}
}