結果

問題 No.40 多項式の割り算
ユーザー J31831276
提出日時 2018-12-30 03:50:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 710 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 56,996 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 14:37:13
合計ジャッジ時間 1,613 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

#define ll long long

using namespace std;

int main(){

   int d;
   cin>>d;

   int tmp;
   int f=0,s=0;
   int a[10001];
   for(int i=0;i<=d;++i) cin>>a[i];
   if(d<3){
      cout<<d<<endl;
      for(int i=0;i<=d;++i){
          cout<<a[i];
          if(i==d) cout<<endl;
          else cout<<" ";
      }
      return 0;
   }
   for(int i=d;i>=3;--i){
     a[i-2]+=a[i];
     a[i]=0;
   }

   int dem=2;
   /*ここにdemの処理*/
   if(!a[1]) dem=0;
   else if(!a[2]) dem=1;

   cout<<dem<<endl; //次数 
   cout<<a[0];  //定数項
   if(dem>=1) cout<<" "<<a[1];
   if(dem>=2) cout<<" "<<a[2];
   cout<<endl;
   return 0;
}
0