結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー iicafiaxusiicafiaxus
提出日時 2018-06-24 23:23:50
言語 D
(dmd 2.105.2)
結果
WA  
実行時間 -
コード長 1,183 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 118,716 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-03 20:27:16
合計ジャッジ時間 16,367 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,384 KB
testcase_11 WA -
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 3 ms
4,384 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 64 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 48 ms
4,388 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
4,384 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 46 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 846 ms
4,376 KB
testcase_44 AC 22 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long l = read.to!long;
	long h = read.to!long;
	
	int pmax = 100_000;
//	if(h < 10_000) pmax = 100;
	
	debug writeln("pmax:", pmax);
	
	bool[] isCompound = new bool[](pmax);
	for(int i = 2; i < pmax; i ++){
		if(isCompound[i]) continue;
		for(int j = i + i; j < pmax; j += i){
			isCompound[j] = 1;
			}
		}
	debug writeln("isCompound[0 .. 20]:", isCompound[0 .. 20]);
	
	long[] xs = [];
	for(int p = 2; p < pmax; p ++){
		if(isCompound[p]) continue;
		if(p >= l) break;
		if(l <= (h / p) * p) xs ~= (h / p) * p;
		}
	
	xs.sort();
	debug writeln("xs:", xs);
	
	long[] ys;
	{
		long y = 0;
		foreach(x; xs) if(x != y) y = x, ys ~= y;
		}
	debug writeln("ys:", ys);
	
	long answer = 0;
	for(int p = 2; p < pmax; p ++){
		if(isCompound[p]) continue;
		foreach(i, y; ys) if(y % p == 0){
			answer = y;
			ys[i] = 1;
			debug writeln("p:", p, " answer:", answer);
			}
		}
	
	answer.writeln;
	}
0