結果

問題 No.40 多項式の割り算
ユーザー scachescache
提出日時 2014-11-25 17:33:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 257 ms / 5,000 ms
コード長 751 bytes
コンパイル時間 3,430 ms
コンパイル使用メモリ 75,632 KB
実行使用メモリ 61,732 KB
最終ジャッジ日時 2023-08-30 22:59:37
合計ジャッジ時間 12,120 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,840 KB
testcase_01 AC 137 ms
55,808 KB
testcase_02 AC 123 ms
55,660 KB
testcase_03 AC 138 ms
55,476 KB
testcase_04 AC 231 ms
59,868 KB
testcase_05 AC 242 ms
59,884 KB
testcase_06 AC 257 ms
60,448 KB
testcase_07 AC 253 ms
60,096 KB
testcase_08 AC 162 ms
56,624 KB
testcase_09 AC 235 ms
59,300 KB
testcase_10 AC 247 ms
59,844 KB
testcase_11 AC 228 ms
59,020 KB
testcase_12 AC 211 ms
57,224 KB
testcase_13 AC 246 ms
60,124 KB
testcase_14 AC 231 ms
59,040 KB
testcase_15 AC 231 ms
59,352 KB
testcase_16 AC 255 ms
59,932 KB
testcase_17 AC 214 ms
58,864 KB
testcase_18 AC 246 ms
59,804 KB
testcase_19 AC 251 ms
61,732 KB
testcase_20 AC 222 ms
59,168 KB
testcase_21 AC 203 ms
58,944 KB
testcase_22 AC 206 ms
59,168 KB
testcase_23 AC 220 ms
59,556 KB
testcase_24 AC 237 ms
59,288 KB
testcase_25 AC 136 ms
56,020 KB
testcase_26 AC 135 ms
55,740 KB
testcase_27 AC 135 ms
55,768 KB
testcase_28 AC 118 ms
55,780 KB
testcase_29 AC 134 ms
55,480 KB
testcase_30 AC 135 ms
55,684 KB
testcase_31 AC 134 ms
56,080 KB
testcase_32 AC 131 ms
55,784 KB
testcase_33 AC 132 ms
56,300 KB
testcase_34 AC 132 ms
56,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main40 {
	public static void main(String[] args) {
		Main40 p = new Main40();
	}

	public Main40() {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] a = new int[d+1];
		for(int i=a.length-1;i>=0;i--){
			a[i] = sc.nextInt();
		}
		
		solve(a);
	}

	public void solve(int[] a) {
		for(int i=0;i<a.length-3;i++){
			a[i+2] += a[i];
			a[i] = 0;
		}
		
		int first = 0;
		while(first < a.length && a[first]==0){
			first++;
		}
		
		if(first == a.length){
			System.out.println("0\n0");
		}else{
			System.out.println(a.length-first-1);
			for(int i=a.length-1;first<i;i--)
				System.out.print(a[i]+" ");
			System.out.println(a[first]);
		}
	}

}
0