結果

問題 No.40 多項式の割り算
コンテスト
ユーザー gu_21816943
提出日時 2017-06-28 21:57:39
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 1,228 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,688 ms
コンパイル使用メモリ 86,176 KB
実行使用メモリ 43,760 KB
最終ジャッジ日時 2026-09-10 05:09:12
合計ジャッジ時間 4,554 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 1 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main {
	static PrintWriter out = new PrintWriter(System.out);
	static String str;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int d = Integer.parseInt(br.readLine());
		String[] num = br.readLine().split(" ");
		br.close();
		int[] result = new int[d - 1];

		PrintWriter out = new PrintWriter(System.out);

		int i;
		if (d < 3) {
			out.println(d);
			for (i = 0; i < d; i++) {
				out.print(num[i] + " ");
			}
			out.println(num[i]);
		} else {
			int[] tmp = new int[d + 1];
			for (i = 0; i < d + 1; i++) {
				tmp[i] = Integer.parseInt(num[i]);
				if (i < d - 1) {
					result[i] = tmp[i];
				}
			}
			result[d - 2] -= -tmp[d];
			result[d - 3] -= -tmp[d - 1];

			for (i = d-2; i >= 3; i--) {
				result[i-2] -= -result[i];
				result[i]=0;
			}
			int point = 0;
			for (i = 0; i < d - 1; i++) {
				if (result[i] != 0) {
					point = i;
				}
			}
			out.println(point);
			for (i = 0; i < point; i++) {
				out.print(result[i] + " ");
			}
			out.println(result[i]);
		}
		out.flush();
	}
}
0