結果
| 問題 | No.40 多項式の割り算 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-04-10 16:03:08 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 698 bytes | 
| コンパイル時間 | 1,324 ms | 
| コンパイル使用メモリ | 160,676 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-26 20:54:44 | 
| 合計ジャッジ時間 | 2,382 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
ソースコード
#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;
}
            
            
            
        