結果
| 問題 |
No.371 ぼく悪いプライムじゃないよ
|
| コンテスト | |
| ユーザー |
iicafiaxus
|
| 提出日時 | 2018-06-24 23:23:50 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,183 bytes |
| コンパイル時間 | 754 ms |
| コンパイル使用メモリ | 133,268 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-13 01:15:35 |
| 合計ジャッジ時間 | 15,535 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 WA * 21 |
ソースコード
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;
}
iicafiaxus