結果

問題 No.40 多項式の割り算
ユーザー tentententen
提出日時 2023-02-14 14:34:57
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,260 bytes
コンパイル時間 2,545 ms
コンパイル使用メモリ 87,900 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2023-09-24 03:56:46
合計ジャッジ時間 6,590 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,408 KB
testcase_01 AC 43 ms
49,904 KB
testcase_02 AC 43 ms
49,560 KB
testcase_03 AC 43 ms
49,564 KB
testcase_04 AC 71 ms
50,372 KB
testcase_05 AC 72 ms
51,528 KB
testcase_06 AC 88 ms
51,972 KB
testcase_07 AC 85 ms
52,352 KB
testcase_08 AC 44 ms
49,312 KB
testcase_09 AC 81 ms
52,188 KB
testcase_10 AC 81 ms
51,960 KB
testcase_11 AC 71 ms
50,660 KB
testcase_12 AC 60 ms
50,756 KB
testcase_13 AC 89 ms
52,036 KB
testcase_14 AC 70 ms
50,708 KB
testcase_15 AC 68 ms
50,660 KB
testcase_16 AC 87 ms
52,340 KB
testcase_17 AC 59 ms
50,396 KB
testcase_18 AC 87 ms
52,204 KB
testcase_19 AC 90 ms
52,200 KB
testcase_20 AC 67 ms
51,720 KB
testcase_21 AC 56 ms
50,364 KB
testcase_22 AC 55 ms
50,508 KB
testcase_23 AC 74 ms
51,116 KB
testcase_24 AC 77 ms
51,952 KB
testcase_25 AC 43 ms
49,544 KB
testcase_26 AC 42 ms
49,336 KB
testcase_27 AC 43 ms
49,264 KB
testcase_28 RE -
testcase_29 AC 45 ms
49,364 KB
testcase_30 AC 42 ms
49,360 KB
testcase_31 AC 42 ms
49,256 KB
testcase_32 AC 41 ms
49,396 KB
testcase_33 AC 42 ms
49,368 KB
testcase_34 AC 42 ms
49,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] values = new int[n + 1];
        for (int i = n; i >= 0; i--) {
            values[i] = sc.nextInt();
        }
        for (int i = 0; i <= n - 3; i++) {
            values[i + 2] += values[i];
        }
        ArrayList<Integer> ans = new ArrayList<>();
        for (int i = n; i >= n - 2; i--) {
            ans.add(values[i]);
        }
        for (int i = 2; i >= 1; i--) {
            if (ans.get(i) == 0) {
                ans.remove(i);
            } else {
                break;
            }
        }
        System.out.println(ans.size() - 1);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < ans.size(); i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(ans.get(i));
        }
        System.out.println(sb);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0