結果
問題 |
No.40 多項式の割り算
|
ユーザー |
![]() |
提出日時 | 2016-04-15 01:49:43 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 602 bytes |
コンパイル時間 | 442 ms |
コンパイル使用メモリ | 23,168 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-04 09:16:38 |
合計ジャッジ時間 | 1,097 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 1 WA * 31 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:19:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%d",&d); | ^~~~~~~~~~~~~~ main.c:20:20: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | for(i=0;i<=d;i++)scanf("%d",&a[i]); | ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <math.h> int d; int a[10000]; int f(int x){ int ans=0; int i,j; for(i=1;i<=d;i++){ ans=ans+a[i]*pow(x,i); } return ans; } int main(){ int i,j; 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"); else order=1; if(s==0 && t!=0)printf("1\n"); else order=0; if(s==0 && t==0)printf("0\n"); 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; }