結果
| 問題 |
No.1666 累乗数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-03 21:51:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 778 bytes |
| コンパイル時間 | 750 ms |
| コンパイル使用メモリ | 70,860 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-15 12:37:31 |
| 合計ジャッジ時間 | 34,266 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 15 |
コンパイルメッセージ
main.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
40 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
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<int>ps={2,3,5,7,11,13,17,19,23,29};
long cnt(long N)
{
long ans=N>=1;
for(int i=1;i<1<<10;i++)
{
long k=1;
for(int j=0;j<10;j++)if(i>>j&1)k*=ps[j];
long now=sq(N,k)-1;
ans+=__builtin_parity(i)?now:-now;
}
return ans;
}
main()
{
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;
}
}