結果

問題 No.40 多項式の割り算
ユーザー notetonous
提出日時 2016-04-15 02:07:21
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 686 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 37,888 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-01 18:36:17
合計ジャッジ時間 1,808 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <math.h>
int d;
int a[10000];

int f(int x){
  long long int ans=0;
  long long int i,j;
  for(i=1;i<=d;i++){ 
     ans=ans+a[i]*pow(x,i); 
  }
  return ans;
}

int main(){
  int i,j;
  long long int s,t,u;
  int order=2;
  scanf("%d",&d);
  for(i=0;i<=d;i++)scanf("%d",&a[i]);
  u=a[0];
  s=(f(1)+f(-1))/2;
  t=(f(1)-f(-1))/2;
  if(s!=0){
    printf("2\n");
    order=2;
  }
  else{
    if(t!=0){
      printf("1\n");
      order=1;
    }
    else {
      printf("0\n");
      order=0;
    }
  }
 
  if(order==0){
    printf("%d\n",u);
  }
  else if(order==1){
    printf("%d %d\n",u,t);
    
  }
  else{
    printf("%d %d %d\n",u,t,s);
  }
 
  return 0;
}
0