結果
問題 | No.40 多項式の割り算 |
ユーザー |
![]() |
提出日時 | 2016-08-08 18:42:27 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 745 ms |
コンパイル使用メモリ | 63,460 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 07:28:32 |
合計ジャッジ時間 | 1,976 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int d; cin >> d; vector<int> a(d + 1), b; for (auto i = 0; i <= d; i++) { cin >> a[i]; } for (auto i = d; i >= 3; i--) { auto coef = a[i]; a[i] -= coef; a[i - 2] += coef; } int degree = 0; for (auto i = 0; i < a.size(); i++) { if (a[i] != 0) degree = i; b.push_back(a[i]); } cout << degree << endl; for (auto i = 0; i <= degree; i++) { cout << (i == 0 ? "" : " ") << b[i]; } cout << endl; return 0; }