結果
問題 |
No.688 E869120 and Constructing Array 2
|
ユーザー |
![]() |
提出日時 | 2018-05-19 14:27:37 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 965 bytes |
コンパイル時間 | 729 ms |
コンパイル使用メモリ | 110,568 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 01:03:27 |
合計ジャッジ時間 | 1,413 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; long nck(int n, int k) { if (k == 0) return 1; if (n == 0) return 0; return nck(n - 1, k - 1) * n / k; } void calc(int k) { for (int i = 2; i <= 30; i++) { for (int j = 0; j <= 30; j++) { if (i + j > 30) break; long a = nck(i, 2); long b = 2 ^^ j; if (a * b == k) { auto ans = chain(replicate([1], i), replicate([0], j)); writeln(ans.count); writeln(ans.map!(e => e.to!string).join(" ")); return; } } } // not found writeln(1); writeln(0); } void main() { int k = readint; calc(k); }