結果

問題 No.40 多項式の割り算
ユーザー tsunabittsunabit
提出日時 2019-09-06 12:14:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 236 ms / 5,000 ms
コード長 1,178 bytes
コンパイル時間 4,818 ms
コンパイル使用メモリ 76,648 KB
実行使用メモリ 60,976 KB
最終ジャッジ日時 2023-09-05 23:32:08
合計ジャッジ時間 12,476 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
57,000 KB
testcase_01 AC 153 ms
56,716 KB
testcase_02 AC 115 ms
56,064 KB
testcase_03 AC 142 ms
58,720 KB
testcase_04 AC 212 ms
58,764 KB
testcase_05 AC 207 ms
58,704 KB
testcase_06 AC 217 ms
60,512 KB
testcase_07 AC 223 ms
60,976 KB
testcase_08 AC 158 ms
56,804 KB
testcase_09 AC 217 ms
58,632 KB
testcase_10 AC 224 ms
58,988 KB
testcase_11 AC 185 ms
57,324 KB
testcase_12 AC 176 ms
56,924 KB
testcase_13 AC 236 ms
58,944 KB
testcase_14 AC 211 ms
59,348 KB
testcase_15 AC 214 ms
59,300 KB
testcase_16 AC 214 ms
58,720 KB
testcase_17 AC 176 ms
56,560 KB
testcase_18 AC 209 ms
58,896 KB
testcase_19 AC 217 ms
60,208 KB
testcase_20 AC 188 ms
57,056 KB
testcase_21 AC 178 ms
56,812 KB
testcase_22 AC 180 ms
56,792 KB
testcase_23 AC 192 ms
57,108 KB
testcase_24 AC 214 ms
58,632 KB
testcase_25 AC 149 ms
56,884 KB
testcase_26 AC 144 ms
57,168 KB
testcase_27 AC 143 ms
57,084 KB
testcase_28 AC 139 ms
56,880 KB
testcase_29 AC 144 ms
57,124 KB
testcase_30 AC 143 ms
57,340 KB
testcase_31 AC 144 ms
57,000 KB
testcase_32 AC 142 ms
56,888 KB
testcase_33 AC 140 ms
57,272 KB
testcase_34 AC 143 ms
57,120 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 = "";
		int cc = a.length >= 3? 2 : a.length-1;
//		for(int i = 2; -1 < i; i--) {
		for(int i = cc; -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