結果

問題 No.40 多項式の割り算
ユーザー kou6839kou6839
提出日時 2014-11-18 23:14:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 285 ms / 5,000 ms
コード長 1,025 bytes
コンパイル時間 3,689 ms
コンパイル使用メモリ 76,712 KB
実行使用メモリ 63,172 KB
最終ジャッジ日時 2023-08-30 21:06:07
合計ジャッジ時間 13,100 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
56,292 KB
testcase_01 AC 161 ms
56,608 KB
testcase_02 AC 121 ms
55,912 KB
testcase_03 AC 152 ms
56,660 KB
testcase_04 AC 267 ms
61,116 KB
testcase_05 AC 269 ms
60,828 KB
testcase_06 AC 282 ms
61,264 KB
testcase_07 AC 285 ms
61,172 KB
testcase_08 AC 179 ms
56,732 KB
testcase_09 AC 268 ms
61,236 KB
testcase_10 AC 275 ms
60,968 KB
testcase_11 AC 253 ms
60,432 KB
testcase_12 AC 245 ms
60,732 KB
testcase_13 AC 276 ms
61,084 KB
testcase_14 AC 261 ms
60,624 KB
testcase_15 AC 256 ms
61,612 KB
testcase_16 AC 283 ms
63,172 KB
testcase_17 AC 242 ms
59,780 KB
testcase_18 AC 278 ms
61,248 KB
testcase_19 AC 283 ms
61,540 KB
testcase_20 AC 258 ms
60,432 KB
testcase_21 AC 227 ms
60,872 KB
testcase_22 AC 230 ms
60,636 KB
testcase_23 AC 249 ms
59,832 KB
testcase_24 AC 265 ms
60,684 KB
testcase_25 AC 160 ms
56,688 KB
testcase_26 AC 161 ms
56,724 KB
testcase_27 AC 161 ms
56,664 KB
testcase_28 AC 120 ms
55,528 KB
testcase_29 AC 161 ms
56,516 KB
testcase_30 AC 164 ms
56,820 KB
testcase_31 AC 161 ms
56,648 KB
testcase_32 AC 158 ms
56,596 KB
testcase_33 AC 161 ms
56,680 KB
testcase_34 AC 161 ms
56,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] aa = new int[n+1];
		for(int i=n;i>=0;i--){
			aa[i]=sc.nextInt();
		}
		if(n==2){
			String g="";
			for(int i=n;i>=0;i--){
				g+=aa[i]+" ";
			}
			System.out.println(2);
			System.out.println(g.trim());
			return;
		}else if(n==1){
			String g="";
			for(int i=n;i>=0;i--){
				g+=aa[i]+" ";
			}
			System.out.println(1);
			System.out.println(g.trim());
			return;
		}else if(n==0){
			System.out.println(0);
			System.out.println(aa[0]);
			return;
		}
		for(int i=0;i<=n-3;i++){
			int temp=aa[i];
			aa[i]=0;
			aa[i+2]-=-1*temp;
		}
		if(aa[n-2]!=0){
			System.out.println(2);
			System.out.println(aa[n]+" "+aa[n-1]+" "+aa[n-2]);
			return;
		}else if(aa[n-1]!=0){
			System.out.println(1);
			System.out.println(aa[n]+" "+aa[n-1]);
		}else{
			System.out.println(0);
			System.out.println(aa[n]);
		}
	}
}	
0