結果
問題 | No.40 多項式の割り算 |
ユーザー | fujisu |
提出日時 | 2015-03-06 01:01:04 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 176 ms / 5,000 ms |
コード長 | 2,487 bytes |
コンパイル時間 | 2,238 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 53,436 KB |
最終ジャッジ日時 | 2024-06-24 09:51:59 |
合計ジャッジ時間 | 7,491 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 84 ms
51,272 KB |
testcase_01 | AC | 86 ms
51,016 KB |
testcase_02 | AC | 96 ms
51,308 KB |
testcase_03 | AC | 96 ms
51,000 KB |
testcase_04 | AC | 138 ms
53,256 KB |
testcase_05 | AC | 140 ms
53,228 KB |
testcase_06 | AC | 173 ms
53,280 KB |
testcase_07 | AC | 143 ms
53,372 KB |
testcase_08 | AC | 102 ms
52,028 KB |
testcase_09 | AC | 138 ms
53,272 KB |
testcase_10 | AC | 141 ms
53,144 KB |
testcase_11 | AC | 132 ms
52,932 KB |
testcase_12 | AC | 125 ms
53,156 KB |
testcase_13 | AC | 141 ms
53,124 KB |
testcase_14 | AC | 137 ms
53,192 KB |
testcase_15 | AC | 136 ms
53,436 KB |
testcase_16 | AC | 143 ms
53,020 KB |
testcase_17 | AC | 123 ms
52,752 KB |
testcase_18 | AC | 143 ms
53,296 KB |
testcase_19 | AC | 176 ms
53,420 KB |
testcase_20 | AC | 144 ms
53,048 KB |
testcase_21 | AC | 116 ms
51,676 KB |
testcase_22 | AC | 125 ms
53,048 KB |
testcase_23 | AC | 138 ms
53,128 KB |
testcase_24 | AC | 142 ms
53,032 KB |
testcase_25 | AC | 90 ms
52,828 KB |
testcase_26 | AC | 88 ms
51,192 KB |
testcase_27 | AC | 86 ms
51,064 KB |
testcase_28 | AC | 97 ms
51,092 KB |
testcase_29 | AC | 99 ms
52,508 KB |
testcase_30 | AC | 89 ms
51,076 KB |
testcase_31 | AC | 85 ms
50,752 KB |
testcase_32 | AC | 96 ms
51,276 KB |
testcase_33 | AC | 94 ms
50,868 KB |
testcase_34 | AC | 87 ms
50,888 KB |
ソースコード
import java.io.IOException; import java.util.InputMismatchException; public class Main { void run() { MyScanner sc = new MyScanner(); int n = sc.nextInt(); int[] a = sc.nextIntArray(n + 1); for (int i = n; 3 <= i; i--) { int k = a[i]; a[i] -= k; a[i - 2] += k; } int ans = 0; for (int i = 0; i < Math.min(3, a.length); i++) { if (a[i] != 0) { ans = i; } } System.out.println(ans); String tab = ""; for (int i = 0; i <= ans; i++) { System.out.print(tab + a[i]); tab = " "; } } public static void main(String[] args) { new Main().run(); } public void mapDebug(int[][] a) { System.out.println("--------map display---------"); for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.printf("%3d ", a[i][j]); } System.out.println(); } System.out.println("----------------------------" + '\n'); } class MyScanner { int read() { try { return System.in.read(); } catch (IOException e) { throw new InputMismatchException(); } } boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } boolean isEndline(int c) { return c == '\n' || c == '\r' || c == -1; } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } long nextLong() { return Long.parseLong(next()); } long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) array[i] = nextDouble(); return array; } String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } String nextLine() { int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndline(c)); return res.toString(); } } }