結果

問題 No.40 多項式の割り算
ユーザー YamaKasaYamaKasa
提出日時 2018-06-19 00:54:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 287 ms / 5,000 ms
コード長 890 bytes
コンパイル時間 2,684 ms
コンパイル使用メモリ 81,168 KB
実行使用メモリ 61,848 KB
最終ジャッジ日時 2023-09-13 07:01:43
合計ジャッジ時間 11,324 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
57,020 KB
testcase_01 AC 158 ms
57,076 KB
testcase_02 AC 117 ms
55,840 KB
testcase_03 AC 144 ms
56,864 KB
testcase_04 AC 260 ms
60,540 KB
testcase_05 AC 263 ms
59,532 KB
testcase_06 AC 287 ms
61,824 KB
testcase_07 AC 274 ms
61,416 KB
testcase_08 AC 175 ms
56,948 KB
testcase_09 AC 260 ms
61,352 KB
testcase_10 AC 274 ms
61,684 KB
testcase_11 AC 255 ms
61,216 KB
testcase_12 AC 241 ms
60,584 KB
testcase_13 AC 274 ms
61,420 KB
testcase_14 AC 258 ms
61,440 KB
testcase_15 AC 257 ms
61,084 KB
testcase_16 AC 277 ms
61,848 KB
testcase_17 AC 234 ms
60,088 KB
testcase_18 AC 278 ms
61,140 KB
testcase_19 AC 277 ms
61,544 KB
testcase_20 AC 248 ms
58,824 KB
testcase_21 AC 215 ms
60,296 KB
testcase_22 AC 214 ms
61,000 KB
testcase_23 AC 248 ms
60,176 KB
testcase_24 AC 269 ms
61,080 KB
testcase_25 AC 157 ms
57,048 KB
testcase_26 AC 161 ms
56,728 KB
testcase_27 AC 158 ms
56,716 KB
testcase_28 AC 119 ms
55,528 KB
testcase_29 AC 157 ms
58,860 KB
testcase_30 AC 157 ms
56,836 KB
testcase_31 AC 158 ms
57,112 KB
testcase_32 AC 158 ms
56,920 KB
testcase_33 AC 160 ms
57,004 KB
testcase_34 AC 159 ms
56,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int D = scan.nextInt();
		int []a = new int[D + 1];
		for(int i = 0; i <= D; i++) {
			a[i] = scan.nextInt();
		}
		scan.close();
		int r0 = a[0];
		int f1 = sub(a, 1);
		int f2 = sub(a, -1);
		//double r1 = (double)(f1 - f2) / 2;
		//double r2 = -r0 + (double)(f1 + f2) / 2;
		int r1 = (f1 - f2) / 2;
		int r2 = -r0 + (f1 + f2) / 2;
		if(r2 == 0) {
			if(r1 == 0) {
				System.out.println(0);
				System.out.println(r0);
			}else {
				System.out.println(1);
				System.out.println(r0 + " " + r1);
			}
		}else {
			System.out.println(2);
			System.out.println(r0 + " " + r1 + " " + r2);
		}

	}
	public static int sub(int[] a, int k) {
		int t = a[0];
		int x = 1;
		for(int i = 1; i < a.length; i++) {
			x = x * k;
			t += a[i] * x;
		}
		return t;
	}
}
0