結果

問題 No.40 多項式の割り算
ユーザー oooooba
提出日時 2021-09-12 22:33:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,019 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 114,600 KB
最終ジャッジ日時 2025-01-24 13:23:13
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std; // NOLINT

int main() {
    int32_t d;
    cin >> d;
    vector<int32_t> as(d + 1);
    for (auto &&d : as) {
        cin >> d;
    }
    for (auto i = d; i >= 3; --i) {
        if (as[i] == 0)
            continue;
        as[i - 2] += as[i];
        as[i] = 0;
    }
    int32_t ans_d = -1;
    for (auto i = 2; i >= 0; --i) {
        if (as[i] != 0) {
            ans_d = i;
            break;
        }
    }
    if (ans_d == -1) {
        cout << 0 << endl;
        cout << 0 << endl;
        return 0;
    }
    cout << ans_d << endl;
    bool first = true;
    for (auto i = 0; i <= ans_d; ++i) {
        cout << (first ? "" : " ") << as[i];
        first = false;
    }
    cout << endl;
    return 0;
}
0