結果
| 問題 | No.40 多項式の割り算 | 
| コンテスト | |
| ユーザー |  ldsyb | 
| 提出日時 | 2017-06-21 20:25:24 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 28 ms / 5,000 ms | 
| コード長 | 782 bytes | 
| コンパイル時間 | 774 ms | 
| コンパイル使用メモリ | 78,992 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-02 10:59:29 | 
| 合計ジャッジ時間 | 2,094 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;
template <typename T>
string join(vector<T> v, string s = " "){
	stringstream ss;
	for(int i = 0; i < v.size(); i++){
		if(i) ss << s;
		ss << v[i];
	}
	return ss.str();
}
int main(){
	int d;
	cin >> d;
	d++;
	vector<int> a(d), v;
	for(int i = 0; i < d; i++) cin >> a[i];
	reverse(a.begin(), a.end());
	for(int i = 0; i < max(0, d - 3); i++) a[i + 2] += a[i];
	for(int i = 0; i < d; i++) cerr << a[i] << ' ';
		cerr << endl;
	bool f = false;
	for(int i = 0; i < min(d, 3); i++) if(f || a[d - min(d, 3) + i]){
		v.emplace_back(a[d - min(d, 3) + i]);
		f = true;
	}
	if(!f) v.emplace_back(0);
	reverse(v.begin(), v.end());
	cout << v.size() - 1 << endl;
	cout << join(v) << endl;
}
            
            
            
        