結果

問題 No.40 多項式の割り算
ユーザー fujisufujisu
提出日時 2015-03-06 00:59:48
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,467 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 76,204 KB
実行使用メモリ 56,856 KB
最終ジャッジ日時 2023-09-06 15:27:19
合計ジャッジ時間 8,033 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
52,412 KB
testcase_01 AC 86 ms
53,444 KB
testcase_02 AC 93 ms
52,484 KB
testcase_03 AC 82 ms
53,412 KB
testcase_04 AC 133 ms
51,756 KB
testcase_05 AC 127 ms
54,168 KB
testcase_06 AC 136 ms
53,980 KB
testcase_07 AC 142 ms
56,256 KB
testcase_08 AC 91 ms
53,540 KB
testcase_09 AC 127 ms
53,592 KB
testcase_10 AC 158 ms
56,856 KB
testcase_11 AC 129 ms
53,756 KB
testcase_12 AC 111 ms
53,652 KB
testcase_13 AC 132 ms
51,700 KB
testcase_14 AC 121 ms
54,024 KB
testcase_15 AC 121 ms
53,772 KB
testcase_16 AC 137 ms
53,852 KB
testcase_17 AC 111 ms
53,552 KB
testcase_18 AC 133 ms
54,224 KB
testcase_19 AC 158 ms
56,344 KB
testcase_20 AC 116 ms
53,892 KB
testcase_21 AC 109 ms
53,560 KB
testcase_22 AC 96 ms
52,412 KB
testcase_23 AC 113 ms
53,688 KB
testcase_24 AC 123 ms
53,480 KB
testcase_25 AC 90 ms
52,704 KB
testcase_26 AC 86 ms
52,336 KB
testcase_27 AC 87 ms
53,460 KB
testcase_28 RE -
testcase_29 AC 76 ms
52,064 KB
testcase_30 AC 83 ms
52,700 KB
testcase_31 AC 82 ms
53,200 KB
testcase_32 AC 76 ms
52,216 KB
testcase_33 AC 88 ms
51,128 KB
testcase_34 AC 91 ms
53,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.InputMismatchException;

public class Main {
	void run() {
		MyScanner sc = new MyScanner();

		int n = sc.nextInt();
		int[] a = sc.nextIntArray(n + 1);

		for (int i = n; 3 <= i; i--) {
			int k = a[i];
			a[i] -= k;
			a[i - 2] += k;
		}

		int ans = 0;
		for (int i = 0; i < 3; i++) {
			if (a[i] != 0) {
				ans = i;
			}
		}
		System.out.println(ans);
		String tab = "";
		for (int i = 0; i <= ans; i++) {
			System.out.print(tab + a[i]);
			tab = " ";
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}
0