結果

問題 No.3027 f-列とh-列
ユーザー Zhiyuan Chen
提出日時 2025-02-21 22:05:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,229 bytes
コンパイル時間 1,090 ms
コンパイル使用メモリ 70,636 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-21 22:06:01
合計ジャッジ時間 1,864 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;

vector<vector<ll>> precompute_combinations(int max_n) {
    vector<vector<ll>> C(max_n + 1, vector<ll>(max_n + 1, 0));
    for (int n = 0; n <= max_n; ++n) {
        C[n][0] = 1;
        for (int k = 1; k <= n; ++k) {
            C[n][k] = C[n-1][k-1] + C[n-1][k];
        }
    }
    return C;
}

int main() {
    int N;
    cin >> N;
    vector<ll> F(N + 1);
    for (int i = 0; i <= N; ++i) {
        cin >> F[i];
    }

    auto C = precompute_combinations(25);

    vector<ll> H(N + 1, 0);

    // 修正后的核心逻辑
    for (int i = 0; i <= N; ++i) { // 遍历原多项式的每个项 F_i X^{N-i}
        int exponent = N - i;      // 当前项的次数 (X-1)^exponent
        for (int j = 0; j <= exponent; ++j) { // 展开后的项次
            ll comb = C[exponent][j];
            ll sign = (exponent - j) % 2 ? -1 : 1;
            int target_degree = N - j; // 新多项式的次数为 N-j
            H[target_degree] += F[i] * comb * sign;
        }
    }

    // 输出顺序保持 H_0 到 H_N
    for (int i = 0; i <= N; ++i) {
        cout << H[i];
        if (i != N) cout << " ";
    }
    cout << endl;

    return 0;
}
0