結果

問題 No.40 多項式の割り算
ユーザー shinshin
提出日時 2022-06-05 16:28:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,138 bytes
コンパイル時間 3,737 ms
コンパイル使用メモリ 79,008 KB
実行使用メモリ 68,296 KB
最終ジャッジ日時 2023-10-21 03:13:35
合計ジャッジ時間 44,499 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
53,620 KB
testcase_01 AC 56 ms
53,612 KB
testcase_02 AC 56 ms
53,592 KB
testcase_03 AC 58 ms
53,604 KB
testcase_04 AC 1,281 ms
60,988 KB
testcase_05 WA -
testcase_06 AC 3,438 ms
63,112 KB
testcase_07 AC 4,076 ms
68,296 KB
testcase_08 AC 107 ms
57,848 KB
testcase_09 AC 1,795 ms
61,372 KB
testcase_10 AC 3,197 ms
60,908 KB
testcase_11 AC 1,101 ms
60,828 KB
testcase_12 WA -
testcase_13 AC 3,096 ms
61,024 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3,093 ms
59,284 KB
testcase_17 AC 418 ms
60,468 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 343 ms
60,952 KB
testcase_22 AC 342 ms
61,428 KB
testcase_23 AC 885 ms
60,956 KB
testcase_24 WA -
testcase_25 AC 58 ms
52,488 KB
testcase_26 AC 59 ms
51,580 KB
testcase_27 WA -
testcase_28 AC 57 ms
53,536 KB
testcase_29 AC 57 ms
53,596 KB
testcase_30 AC 57 ms
53,604 KB
testcase_31 AC 57 ms
53,600 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 59 ms
52,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class No40 {

	public static void main(String[] args) throws IOException{
		//多項式の割り算
		String[] str = readStr();
		int D = Integer.parseInt(str[0]);
		int[] a = new int[D + 1];
		
		for(int i = 0;i <= D;i++) {
			a[D - i] = Integer.parseInt(str[1].split(" ")[i]);
		}
		
		for(int i = 0;i < D - 2;i++) {
			a[i + 2] += a[i];
			a[i] = 0;
		}
		
		int Dd = 0;
		for(int i = Math.max(0, D - 2);i <= D ;i++) {
			if(a[i] > 0) {
				Dd = D - i;
				break;
			}
			
		}
		
		System.out.println(Dd);
		for(int i = D;i >= D - Dd;i--) {
			System.out.print(a[i]);
			if(i == D - Dd) {
				System.out.println();
			}else {
				System.out.print(" ");
			}
		}



	}

	public static String[] readStr() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<>();

		do {
			list.add(br.readLine());
		}while(br.ready());

		br.close();

		String[] text = new String[list.size()];
		list.toArray(text);

		return text;

	}
}
0