結果
| 問題 |
No.40 多項式の割り算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-12 12:32:37 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 497 bytes |
| コンパイル時間 | 816 ms |
| コンパイル使用メモリ | 106,792 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 06:22:16 |
| 合計ジャッジ時間 | 1,684 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto d = readln.chomp.to!size_t;
auto ai = readln.split.to!(int[]);
ai.reverse();
auto bi = [1, 0, -1, 0];
while (ai.length >= bi.length) {
auto ci = ai.take(bi.length);
ci[] -= bi[] * ci[0];
ai = ai.drop(1);
}
ai = ai.find!"a != 0";
ai.reverse();
if (ai.empty) {
writeln(0);
writeln(0);
} else {
writeln(ai.length - 1);
writeln(ai.to!(string[]).join(" "));
}
}