結果
問題 | No.40 多項式の割り算 |
ユーザー |
![]() |
提出日時 | 2015-10-10 22:03:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 724 bytes |
コンパイル時間 | 425 ms |
コンパイル使用メモリ | 61,136 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-21 06:16:04 |
合計ジャッジ時間 | 1,516 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main() { int D; vector<int> a; cin >> D; a.resize(D + 1); for (int i = 0; i <= D; ++i) { int tmp; cin >> tmp; a[D - i] = tmp; } while (3 < a.size()) { int first = a[0], second = a[1], third = a[2]; third = third + first; if (second != 0) { a[2] = third; a.erase(a.begin(), a.begin() + 1); } else { a[2] = third; a.erase(a.begin(), a.begin() + 2); } } while (1 < a.size() && a[0] == 0) { a.erase(a.begin(), a.begin() + 1); } cout << a.size() - 1 << endl; for (int i = 0; i < a.size(); ++i) { cout << a[a.size() - 1 - i]; if (i != a.size() - 1) cout << " "; else cout << endl; } return 0; }