結果

問題 No.40 多項式の割り算
ユーザー scache
提出日時 2014-11-25 17:33:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 299 ms / 5,000 ms
コード長 751 bytes
コンパイル時間 3,442 ms
コンパイル使用メモリ 81,180 KB
実行使用メモリ 48,704 KB
最終ジャッジ日時 2025-01-02 21:51:11
合計ジャッジ時間 11,485 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main40 {
	public static void main(String[] args) {
		Main40 p = new Main40();
	}

	public Main40() {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] a = new int[d+1];
		for(int i=a.length-1;i>=0;i--){
			a[i] = sc.nextInt();
		}
		
		solve(a);
	}

	public void solve(int[] a) {
		for(int i=0;i<a.length-3;i++){
			a[i+2] += a[i];
			a[i] = 0;
		}
		
		int first = 0;
		while(first < a.length && a[first]==0){
			first++;
		}
		
		if(first == a.length){
			System.out.println("0\n0");
		}else{
			System.out.println(a.length-first-1);
			for(int i=a.length-1;first<i;i--)
				System.out.print(a[i]+" ");
			System.out.println(a[first]);
		}
	}

}
0