結果

問題 No.1666 累乗数
ユーザー kotatsugamekotatsugame
提出日時 2021-09-03 21:51:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 778 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 69,412 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-21 21:21:26
合計ジャッジ時間 35,660 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
4,376 KB
testcase_01 AC 1,599 ms
4,380 KB
testcase_02 AC 1,604 ms
4,380 KB
testcase_03 AC 1,606 ms
4,504 KB
testcase_04 AC 1,610 ms
4,376 KB
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:40:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   40 | main()
      | ^~~~

ソースコード

diff #

#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;
	}
}
0