結果

問題 No.40 多項式の割り算
ユーザー NotationNapNotationNap
提出日時 2015-05-05 08:33:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 688 bytes
コンパイル時間 2,472 ms
コンパイル使用メモリ 148,344 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-19 07:00:54
合計ジャッジ時間 3,127 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

typedef long long Int;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i))

vector<int> remainder(vector<int> a, vector<int> b) {
	for (int i = 0; i + b.size() <= a.size(); i++) {
		int d = a[i] / b[0];
		for (int j = 0; j < b.size(); j++) {
			a[i + j] -= b[j] * d;
		}
	}
	while (a.size() >= 2 && a[0] == 0) a.erase(a.begin());
	return a;
}

int main() {
	int D; cin >> D;
	vector<int> a(D+1);
	REP(i, D+1) {
		cin >> a[D-i];
	}
	vector<int> b{1,0,-1,0};

	vector<int> r = remainder(a, b);

	reverse(r.begin(), r.end());
	cout << (r.size()-1) << endl;
	cout << r[0];
	for (int i = 1; i < r.size(); i++) cout << " " << r[i];
	cout << endl;
}
0