結果

問題 No.40 多項式の割り算
ユーザー tempura-sama
提出日時 2016-04-20 12:01:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 469 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 55,104 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 14:22:06
合計ジャッジ時間 1,317 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

#define D 10000

int d;
int a[D+1];
int b[] = { 0, -1, 0, 1 };

int main()
{
	cin >> d;
	for ( int i = 0; i < d + 1; i++ ) {
		cin >> a[i];
	}

	for ( int i = d; i >= 3; i-- ) {
		int x = a[i];
		a[i] -= b[3] * x; a[i-2] -= b[1] * x;
	}

	int rd;
	for ( rd = d; rd > 0 && a[rd] == 0; rd-- ) {}

	cout << rd;
	for ( int i = 0; i < rd + 1; i++ ) {
		cout << (i == 0 ? "\n" : " ");
		cout << a[i];
	}
	cout << endl;

	return 0;
}
0