結果

問題 No.40 多項式の割り算
ユーザー notetonousnotetonous
提出日時 2016-04-15 02:07:21
言語 C90
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 686 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 23,552 KB
最終ジャッジ日時 2024-04-27 02:19:41
合計ジャッジ時間 598 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function ‘main’:
main.c:40:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   40 |     printf("%d\n",u);
      |             ~^    ~
      |              |    |
      |              int  long long int
      |             %lld
main.c:43:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   43 |     printf("%d %d\n",u,t);
      |             ~^       ~
      |              |       |
      |              int     long long int
      |             %lld
main.c:43:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long long int’ [-Wformat=]
   43 |     printf("%d %d\n",u,t);
      |                ~^      ~
      |                 |      |
      |                 int    long long int
      |                %lld
main.c:47:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   47 |     printf("%d %d %d\n",u,t,s);
      |             ~^          ~
      |              |          |
      |              int        long long int
      |             %lld
main.c:47:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long long int’ [-Wformat=]
   47 |     printf("%d %d %d\n",u,t,s);
      |                ~^         ~
      |                 |         |
      |                 int       long long int
      |                %lld
main.c:47:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long long int’ [-Wformat=]
   47 |     printf("%d %d %d\n",u,t,s);
      |                   ~^        ~
      |                    |        |
      |                    int      long long int
      |                   %lld
main.c:19:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  

ソースコード

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