結果
| 問題 |
No.371 ぼく悪いプライムじゃないよ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-26 15:26:30 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,035 bytes |
| コンパイル時間 | 792 ms |
| コンパイル使用メモリ | 114,304 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-06-12 06:06:55 |
| 合計ジャッジ時間 | 4,007 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 TLE * 1 -- * 23 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
void main() {
immutable int p_max = 10^^5;
bool[p_max] pt;
long[] primes;
foreach (i; 2..p_max) pt[i] = true;
foreach (i; 2..p_max) {
if (pt[i]) {
primes ~= i;
foreach (j; iota(i+i, p_max, i))
pt[j] = false;
}
}
primes.reverse;
auto N = primes.length;
long L, H;
scanf("%lld %lld", &L, &H);
foreach (i, p; enumerate(primes)) {
if (p > H)
continue;
for (long j = H/p; (j>1)&&(p*j>=L); j--) {
bool flag = true;
foreach (k; iota(N-1, i, -1)) {
if (j % primes[k] == 0) {
flag = false;
break;
}
}
if (flag) {
writeln(p * j, " ", );
return;
}
}
}
}