結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー kotatsugamekotatsugame
提出日時 2020-04-22 23:02:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 1,000 ms
コード長 472 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 65,368 KB
実行使用メモリ 23,888 KB
最終ジャッジ日時 2023-08-02 12:39:43
合計ジャッジ時間 5,560 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
9,468 KB
testcase_01 AC 36 ms
9,672 KB
testcase_02 AC 36 ms
9,456 KB
testcase_03 AC 35 ms
9,524 KB
testcase_04 AC 35 ms
9,460 KB
testcase_05 AC 35 ms
9,464 KB
testcase_06 AC 35 ms
9,800 KB
testcase_07 AC 36 ms
9,496 KB
testcase_08 AC 35 ms
9,544 KB
testcase_09 AC 35 ms
9,496 KB
testcase_10 AC 36 ms
9,468 KB
testcase_11 AC 36 ms
9,512 KB
testcase_12 AC 35 ms
9,528 KB
testcase_13 AC 36 ms
9,460 KB
testcase_14 AC 35 ms
9,588 KB
testcase_15 AC 36 ms
9,612 KB
testcase_16 AC 35 ms
9,460 KB
testcase_17 AC 35 ms
9,548 KB
testcase_18 AC 35 ms
9,636 KB
testcase_19 AC 36 ms
9,664 KB
testcase_20 AC 51 ms
11,320 KB
testcase_21 AC 36 ms
9,544 KB
testcase_22 AC 139 ms
23,864 KB
testcase_23 AC 35 ms
9,500 KB
testcase_24 AC 44 ms
9,916 KB
testcase_25 AC 146 ms
23,832 KB
testcase_26 AC 36 ms
9,552 KB
testcase_27 AC 35 ms
9,536 KB
testcase_28 AC 35 ms
9,460 KB
testcase_29 AC 38 ms
9,504 KB
testcase_30 AC 140 ms
23,884 KB
testcase_31 AC 139 ms
23,800 KB
testcase_32 AC 137 ms
23,804 KB
testcase_33 AC 144 ms
23,848 KB
testcase_34 AC 135 ms
23,864 KB
testcase_35 AC 137 ms
23,804 KB
testcase_36 AC 137 ms
23,888 KB
testcase_37 AC 141 ms
23,852 KB
testcase_38 AC 147 ms
23,860 KB
testcase_39 AC 141 ms
23,880 KB
testcase_40 AC 147 ms
23,848 KB
testcase_41 AC 145 ms
23,808 KB
testcase_42 AC 147 ms
23,844 KB
testcase_43 AC 37 ms
9,596 KB
testcase_44 AC 36 ms
9,464 KB
testcase_45 AC 35 ms
9,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-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