結果

問題 No.40 多項式の割り算
ユーザー takeya_okino
提出日時 2017-10-27 18:57:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 294 ms / 5,000 ms
コード長 731 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 76,384 KB
実行使用メモリ 49,288 KB
最終ジャッジ日時 2024-11-21 21:21:28
合計ジャッジ時間 10,992 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int r0 = 0;
    int r1 = 0;
    int r2 = 0;
    for(int i = 0; i <= d; i++) {
      int a = sc.nextInt();
      if(i == 0) r0 = a;
      r1 += a;
      if(i % 2 == 0) {
        r2 += a;
      } else {
        r2 -= a;
      }
    }
    int c = r0;
    int a = (r1 + r2 - 2 * c) / 2;
    int b = r1 - a - c;
    if(a != 0) {
      System.out.println(2);
      System.out.println(c + " " + b + " " + a);
    } else if(b != 0) {
      System.out.println(1);
      System.out.println(c + " " + b);
    } else {
      System.out.println(0);
      System.out.println(c);
    }
  }
}
0