結果
| 問題 |
No.689 E869120 and Constructing Array 3
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-18 23:25:43 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 705 bytes |
| コンパイル時間 | 1,152 ms |
| コンパイル使用メモリ | 116,736 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-13 01:02:45 |
| 合計ジャッジ時間 | 3,240 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | WA * 13 |
ソースコード
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, std.bitmanip, std.regex;
void main() {
auto K = readln.chomp.to!int;
bool is_prime(int n) {
for (int i = 2; i * i <= n; ++i)
if (n % i == 0)
return false;
return true;
}
int[] A = K % 2 ? [1, 1] : [2, 2];
int x = K % 2 ? 2 : 3;
foreach (i; 1..20) {
if (!((K >> i) & 1)) continue;
foreach (j; 0..i) A ~= x;
x += 2;
while (!is_prime(x+A.front)) x += 2;
}
A.length.writeln;
A.map!(to!string).join(" ").writeln;
}