結果

問題 No.40 多項式の割り算
ユーザー fujisufujisu
提出日時 2015-03-06 01:01:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 2,487 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 78,012 KB
実行使用メモリ 55,916 KB
最終ジャッジ日時 2023-09-06 15:27:37
合計ジャッジ時間 7,813 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
52,420 KB
testcase_01 AC 77 ms
52,124 KB
testcase_02 AC 76 ms
53,356 KB
testcase_03 AC 84 ms
52,080 KB
testcase_04 AC 131 ms
53,936 KB
testcase_05 AC 131 ms
53,848 KB
testcase_06 AC 135 ms
53,660 KB
testcase_07 AC 130 ms
52,104 KB
testcase_08 AC 90 ms
52,204 KB
testcase_09 AC 123 ms
53,920 KB
testcase_10 AC 135 ms
55,916 KB
testcase_11 AC 116 ms
53,620 KB
testcase_12 AC 119 ms
53,576 KB
testcase_13 AC 135 ms
54,116 KB
testcase_14 AC 129 ms
53,724 KB
testcase_15 AC 129 ms
53,632 KB
testcase_16 AC 138 ms
53,788 KB
testcase_17 AC 111 ms
53,868 KB
testcase_18 AC 120 ms
53,800 KB
testcase_19 AC 132 ms
53,800 KB
testcase_20 AC 119 ms
53,276 KB
testcase_21 AC 101 ms
53,912 KB
testcase_22 AC 96 ms
52,328 KB
testcase_23 AC 121 ms
51,592 KB
testcase_24 AC 124 ms
55,776 KB
testcase_25 AC 83 ms
53,108 KB
testcase_26 AC 83 ms
52,528 KB
testcase_27 AC 95 ms
52,376 KB
testcase_28 AC 76 ms
52,452 KB
testcase_29 AC 79 ms
52,004 KB
testcase_30 AC 85 ms
53,040 KB
testcase_31 AC 87 ms
53,368 KB
testcase_32 AC 91 ms
52,364 KB
testcase_33 AC 80 ms
50,744 KB
testcase_34 AC 83 ms
52,732 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 < Math.min(3, a.length); 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