結果

問題 No.40 多項式の割り算
コンテスト
ユーザー kaffelun
提出日時 2018-04-10 16:03:08
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 698 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,037 ms
コンパイル使用メモリ 179,284 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-13 16:03:14
合計ジャッジ時間 2,272 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
// 方針:
// x^3 - x = (x - 1)x(x + 1) を利用して代入法で解決
int main() {
	#ifdef DEBUG
	std::ifstream in("/home/share/inputf.in");
	std::cin.rdbuf(in.rdbuf());
	#endif
	int D;
	cin >> D;
	D++;
	int64_t a, b, c;
	vector<int> A(D);
	// s = A(1), t = A(-1)
	int s = 0, t = 0;
	for(int i = 0; i < D; i++) {
		cin >> A[i];
		s += A[i];
		t += (1 - (i % 2) * 2) * A[i];
	}
	c = A.front();
	a = (s + t - 2 * c) / 2;
	b = (s - t) / 2;
	if(a == 0) {
		if(b == 0) {
			cout << 0 << endl;
			cout << c;
		} else {
			cout << 1 << endl;
			cout << c << " " << b;
		}
	} else {
		cout << 2 << endl;
		cout << c << " " << b << " " << a;
	}
	return 0;
}
0