結果
問題 | No.265 数学のテスト |
ユーザー | yuki2006 |
提出日時 | 2015-08-07 21:28:16 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,242 bytes |
コンパイル時間 | 3,662 ms |
コンパイル使用メモリ | 74,240 KB |
実行使用メモリ | 56,676 KB |
最終ジャッジ日時 | 2023-09-25 05:58:18 |
合計ジャッジ時間 | 9,982 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 177 ms
56,448 KB |
testcase_01 | AC | 185 ms
53,848 KB |
testcase_02 | WA | - |
testcase_03 | AC | 153 ms
55,804 KB |
testcase_04 | AC | 156 ms
55,716 KB |
testcase_05 | AC | 180 ms
56,496 KB |
testcase_06 | AC | 155 ms
56,340 KB |
testcase_07 | AC | 180 ms
56,012 KB |
testcase_08 | AC | 178 ms
56,056 KB |
testcase_09 | AC | 153 ms
55,988 KB |
testcase_10 | AC | 152 ms
56,320 KB |
testcase_11 | AC | 178 ms
56,676 KB |
testcase_12 | AC | 126 ms
54,308 KB |
testcase_13 | AC | 145 ms
55,976 KB |
testcase_14 | AC | 140 ms
56,204 KB |
testcase_15 | AC | 125 ms
55,904 KB |
testcase_16 | AC | 140 ms
55,888 KB |
testcase_17 | AC | 119 ms
55,984 KB |
testcase_18 | AC | 121 ms
56,116 KB |
testcase_19 | AC | 122 ms
56,148 KB |
testcase_20 | AC | 126 ms
55,840 KB |
testcase_21 | AC | 122 ms
56,036 KB |
testcase_22 | AC | 141 ms
55,804 KB |
testcase_23 | AC | 122 ms
55,968 KB |
testcase_24 | AC | 122 ms
56,480 KB |
testcase_25 | AC | 148 ms
55,924 KB |
testcase_26 | AC | 126 ms
56,340 KB |
testcase_27 | AC | 122 ms
55,728 KB |
testcase_28 | AC | 130 ms
55,448 KB |
testcase_29 | AC | 124 ms
55,900 KB |
testcase_30 | AC | 130 ms
55,848 KB |
testcase_31 | AC | 122 ms
56,096 KB |
testcase_32 | AC | 122 ms
56,420 KB |
testcase_33 | AC | 125 ms
55,912 KB |
testcase_34 | AC | 122 ms
55,948 KB |
testcase_35 | AC | 122 ms
56,244 KB |
ソースコード
import java.util.Scanner; public class Yuki265 { long pow(int s, int p) { long tmp = 1; for (int i = s; i <= p; i++) { tmp *= i; } return tmp; } void endTerm(int[] consts, int dimension, int level, long term) { int t = dimension - level; long l = term; if (t < 0) { l *= 0; t = 0; } else { l *= pow(t + 1, dimension); } consts[t] += l; } public Yuki265() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int d = scanner.nextInt(); String S = scanner.next(); long term = 1; int level = 0; int dimension = 0; boolean lastTerm = false; int[] consts = new int[d + 1]; for (int i = 0; i < N; i++) { final char c = S.charAt(i); if (Character.isDigit(c)) { term *= c - '0'; lastTerm = true; } else if (c == 'x') { dimension++; lastTerm = true; } else if (c == '+') { if (lastTerm) { endTerm(consts, dimension, level, term); } term = 1; dimension = 0; } else if (c == 'd') { level++; lastTerm = false; } else if (c == '}') { if (lastTerm) { endTerm(consts, dimension, level, term); } level--; term = 1; // x*d(x) がないので リセットする。 dimension = 0; lastTerm = false; } else if (c == '{') { lastTerm = false; } else if (c == '*') { lastTerm = false; } } if (lastTerm) { endTerm(consts, dimension, level, term); } for (int i = 0; i < d + 1; i++) { if (i > 0) { System.out.print(" "); } System.out.print(consts[i]); } } public static void main(String[] args) { Yuki265 hoge = new Yuki265(); } }