結果

問題 No.40 多項式の割り算
ユーザー masa
提出日時 2015-01-30 17:24:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 515 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 62,044 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 04:26:30
合計ジャッジ時間 1,345 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
	int d;

	cin >> d;
	vector<int> a(d + 2, 0);
	for (int i = 0; i <= d; i++) {
		cin >> a[i];
	}

	// x^3 - x
	for (int i = d; i >= 3; i--) {
		a[i - 2] += a[i];
		a[i] = 0;
	}

	int maxd;
	if (a[2] != 0) {
		maxd = 2;
	} else {
		maxd = a[1] != 0 ? 1 : 0;
	}

	printf("%d\n", maxd);
	for (int i = 0; i <= maxd; i++) {
		printf("%d%c", a[i], i == maxd ? '\n' : ' ');
	}

	return 0;
}
0