結果
| 問題 | No.40 多項式の割り算 | 
| コンテスト | |
| ユーザー |  troro_kelp | 
| 提出日時 | 2018-10-07 12:51:07 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 1,652 bytes | 
| コンパイル時間 | 861 ms | 
| コンパイル使用メモリ | 98,300 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 14:12:48 | 
| 合計ジャッジ時間 | 2,304 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 | 
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:75:17: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
   75 |         cout << c << endl;
      |                 ^
main.cpp:59:19: note: 'c' was declared here
   59 |     int a=0, b=0, c;
      |                   ^
            
            ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
#include <sstream>
using namespace std;
const constexpr int INF = 1e9;
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;
struct Less{
   bool operator()(const pair<string, int>&a, const pair<string, int>&b){
        if(a.first==b.first){
            return a.second < b.second;
        }
       return a.first < b.first;
    }
};
const constexpr ll MOD = 1e9 + 7;
ll extGCD(ll a, ll b, ll& x, ll& y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}
ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}
int main() {
    int D; cin >> D;
    int a=0, b=0, c;
    int sum1=0; // x=1のとき
    int sum2=0; // x=-1のとき
    REP(i, D+1){
        int n; cin >> n;
        if(i==0) c = n;
        sum1+=n;
        
        if(i%2==0) sum2+=n;
        else sum2-=n;
    }
    a=(sum1+sum2-2*c)/2;
    b=(sum1-sum2)/2;
    
    if(a==0&&b==0){
        cout << 0 << endl;
        cout << c << endl;
    }else if(a==0){
        cout << 1 << endl;
        cout << c << " "<< b <<  endl;
    }else{
        cout << 2 << endl;
        cout << c << " " << b << " " << a << endl;
    }
    
    
    return 0;
}
            
            
            
        