結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー kotatsugamekotatsugame
提出日時 2020-04-22 23:02:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 1,000 ms
コード長 472 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 64,884 KB
実行使用メモリ 24,144 KB
最終ジャッジ日時 2024-04-20 12:46:34
合計ジャッジ時間 6,015 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
7,680 KB
testcase_01 AC 34 ms
7,680 KB
testcase_02 AC 36 ms
7,680 KB
testcase_03 AC 35 ms
7,680 KB
testcase_04 AC 35 ms
7,796 KB
testcase_05 AC 35 ms
7,808 KB
testcase_06 AC 35 ms
7,680 KB
testcase_07 AC 35 ms
7,808 KB
testcase_08 AC 35 ms
7,680 KB
testcase_09 AC 35 ms
7,680 KB
testcase_10 AC 35 ms
7,808 KB
testcase_11 AC 34 ms
7,680 KB
testcase_12 AC 36 ms
7,680 KB
testcase_13 AC 36 ms
7,808 KB
testcase_14 AC 36 ms
7,680 KB
testcase_15 AC 36 ms
7,780 KB
testcase_16 AC 35 ms
7,552 KB
testcase_17 AC 36 ms
7,808 KB
testcase_18 AC 35 ms
7,552 KB
testcase_19 AC 36 ms
7,680 KB
testcase_20 AC 59 ms
11,520 KB
testcase_21 AC 37 ms
7,680 KB
testcase_22 AC 190 ms
24,072 KB
testcase_23 AC 35 ms
7,808 KB
testcase_24 AC 51 ms
10,112 KB
testcase_25 AC 190 ms
24,064 KB
testcase_26 AC 36 ms
7,680 KB
testcase_27 AC 36 ms
7,808 KB
testcase_28 AC 36 ms
7,552 KB
testcase_29 AC 42 ms
8,960 KB
testcase_30 AC 195 ms
24,012 KB
testcase_31 AC 186 ms
24,112 KB
testcase_32 AC 184 ms
24,144 KB
testcase_33 AC 189 ms
24,064 KB
testcase_34 AC 202 ms
23,908 KB
testcase_35 AC 195 ms
24,080 KB
testcase_36 AC 195 ms
24,016 KB
testcase_37 AC 185 ms
24,008 KB
testcase_38 AC 191 ms
23,980 KB
testcase_39 AC 193 ms
24,060 KB
testcase_40 AC 189 ms
24,060 KB
testcase_41 AC 208 ms
23,936 KB
testcase_42 AC 188 ms
23,892 KB
testcase_43 AC 38 ms
8,320 KB
testcase_44 AC 36 ms
7,808 KB
testcase_45 AC 36 ms
7,680 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[4<<20];
bool isp[4<<20];
main()
{
	cin>>L>>H;
	if(L+(4<<20)<=H)L=H-(4<<20)+1;
	for(int i=2;i<4<<20;i++)isp[i]=true;
	for(int i=2;i<4<<20;i++)if(isp[i])
	{
		for(int j=i+i;j<4<<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