結果

問題 No.40 多項式の割り算
ユーザー tsunabittsunabit
提出日時 2019-09-06 12:05:27
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,101 bytes
コンパイル時間 5,090 ms
コンパイル使用メモリ 75,736 KB
実行使用メモリ 60,132 KB
最終ジャッジ日時 2023-09-05 23:17:45
合計ジャッジ時間 11,572 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
56,736 KB
testcase_01 AC 154 ms
56,920 KB
testcase_02 AC 119 ms
55,868 KB
testcase_03 AC 155 ms
56,836 KB
testcase_04 AC 229 ms
58,892 KB
testcase_05 AC 233 ms
58,980 KB
testcase_06 AC 233 ms
60,132 KB
testcase_07 AC 240 ms
59,988 KB
testcase_08 AC 162 ms
56,836 KB
testcase_09 AC 238 ms
58,952 KB
testcase_10 AC 233 ms
58,252 KB
testcase_11 AC 231 ms
59,176 KB
testcase_12 AC 196 ms
54,592 KB
testcase_13 AC 228 ms
58,908 KB
testcase_14 AC 238 ms
58,888 KB
testcase_15 AC 232 ms
58,700 KB
testcase_16 AC 229 ms
58,748 KB
testcase_17 AC 192 ms
56,360 KB
testcase_18 AC 228 ms
58,640 KB
testcase_19 AC 237 ms
60,120 KB
testcase_20 AC 207 ms
56,428 KB
testcase_21 AC 193 ms
56,760 KB
testcase_22 AC 190 ms
57,068 KB
testcase_23 AC 208 ms
56,836 KB
testcase_24 AC 235 ms
58,920 KB
testcase_25 AC 158 ms
56,828 KB
testcase_26 AC 156 ms
56,920 KB
testcase_27 AC 154 ms
56,776 KB
testcase_28 RE -
testcase_29 AC 155 ms
56,636 KB
testcase_30 AC 153 ms
56,700 KB
testcase_31 AC 153 ms
56,788 KB
testcase_32 AC 156 ms
56,624 KB
testcase_33 AC 154 ms
56,756 KB
testcase_34 AC 152 ms
56,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No40 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = Integer.parseInt(sc.nextLine());
		String[] t = sc.nextLine().split(" ");
//		System.out.println("d = " + d);
		
		int[] a = new int[d+1];
		for(int i = 0; i < d+1; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
//		System.out.println(Arrays.toString(a));
		int[] w = {0, -1, 0, 1};
		for(int i = a.length-1; i > 2; i--) {
			int te = a[i] / w[3];
//			for(int j = w.length-1; j >= 0; j--) {
			for(int c = 0; c < w.length; c++) {
				a[i-c] = a[i-c] - w[3-c]*te;
			}
//			System.out.println(Arrays.toString(a));
		}
//		System.out.println(Arrays.toString(a));
		int ji = 0;
		String str = "";
		for(int i = 2; -1 < i; i--) {
			if(a[i] != 0 && ji < i) {
				ji = i;
			}
			if(a[i] == 0) {
				if(!"".equals(str)) {
					str = a[i] + " " + str;
				}
			}else {
				str = a[i] + " " + str;
			}
		}
		System.out.println(ji);
		if("".equals(str)) {
			System.out.println(0);
		}else {
			System.out.println(str.trim());
		}
		
	}
}
0