結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー kotatsugamekotatsugame
提出日時 2020-04-22 23:02:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 64,760 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-04-20 12:46:14
合計ジャッジ時間 2,902 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
5,504 KB
testcase_01 AC 17 ms
5,504 KB
testcase_02 AC 16 ms
5,376 KB
testcase_03 AC 17 ms
5,632 KB
testcase_04 AC 17 ms
5,632 KB
testcase_05 AC 17 ms
5,632 KB
testcase_06 AC 16 ms
5,376 KB
testcase_07 AC 17 ms
5,632 KB
testcase_08 AC 16 ms
5,632 KB
testcase_09 AC 16 ms
5,632 KB
testcase_10 AC 17 ms
5,504 KB
testcase_11 AC 17 ms
5,632 KB
testcase_12 AC 16 ms
5,632 KB
testcase_13 AC 16 ms
5,376 KB
testcase_14 AC 16 ms
5,504 KB
testcase_15 AC 16 ms
5,632 KB
testcase_16 AC 17 ms
5,632 KB
testcase_17 AC 16 ms
5,504 KB
testcase_18 AC 16 ms
5,504 KB
testcase_19 AC 16 ms
5,504 KB
testcase_20 AC 30 ms
9,600 KB
testcase_21 AC 16 ms
5,632 KB
testcase_22 AC 57 ms
13,696 KB
testcase_23 AC 17 ms
5,376 KB
testcase_24 AC 25 ms
7,936 KB
testcase_25 AC 57 ms
13,824 KB
testcase_26 AC 17 ms
5,632 KB
testcase_27 AC 17 ms
5,376 KB
testcase_28 AC 16 ms
5,504 KB
testcase_29 AC 21 ms
6,656 KB
testcase_30 AC 57 ms
13,824 KB
testcase_31 AC 55 ms
13,568 KB
testcase_32 AC 56 ms
13,824 KB
testcase_33 AC 55 ms
13,696 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 55 ms
13,696 KB
testcase_37 AC 56 ms
13,824 KB
testcase_38 AC 56 ms
13,696 KB
testcase_39 AC 55 ms
13,568 KB
testcase_40 AC 56 ms
13,824 KB
testcase_41 AC 55 ms
13,696 KB
testcase_42 AC 55 ms
13,824 KB
testcase_43 AC 18 ms
5,888 KB
testcase_44 AC 16 ms
5,504 KB
testcase_45 AC 16 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
long L,H;
int divv[2<<20];
bool isp[2<<20];
main()
{
	cin>>L>>H;
	if(L+(2<<20)<=H)L=H-(2<<20)+1;
	for(int i=2;i<2<<20;i++)isp[i]=true;
	for(int i=2;i<2<<20;i++)if(isp[i])
	{
		for(int j=i+i;j<2<<20;j+=i)isp[j]=false;
		long X=(L+i-1)/i*i;
		if(X==i)X+=i;
		for(;X<=H;X+=i)if(divv[H-X]==0)divv[H-X]=i;
	}
	long ans=L;
	if(divv[H-ans]==0)ans++;
	for(long i=ans+1;i<=H;i++)
	{
		if(divv[H-ans]<=divv[H-i])ans=i;
	}
	cout<<ans<<endl;
}
0