結果
問題 |
No.265 数学のテスト
|
ユーザー |
|
提出日時 | 2015-08-07 23:10:39 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,304 bytes |
コンパイル時間 | 3,232 ms |
コンパイル使用メモリ | 79,496 KB |
実行使用メモリ | 54,104 KB |
最終ジャッジ日時 | 2024-07-18 05:18:23 |
合計ジャッジ時間 | 9,205 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 WA * 1 |
ソースコード
import java.util.Scanner; public class Main_yukicoder265 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt() + 1; int d = sc.nextInt(); char[] s = (sc.next() + "+").toCharArray(); int[] a = new int[d + 1]; int cc = 0; int dd = 0; int xx = 0; for (int i = 0; i < n; i++) { char e = s[i]; if (e >= '1' && e <= '9') { cc = e - '0'; } else if (e == 'x') { xx++; if (cc == 0) { cc = 1; } } else if (cc != 0 && (e == '+' || e == '}')) { for (int j = 0; j < dd; j++) { cc *= xx; xx--; } if (xx >= 0) { a[xx] += cc; } cc = 0; xx = 0; if (e == '}') { dd--; } } else if (e == '}') { dd--; } else if (e == 'd') { dd++; } else if (e == '*') { } else if (e == '{') { } } for (int i = 0; i < d + 1; i++) { if (i > 0) { System.out.print(" "); } System.out.print(a[i]); } System.out.println(""); sc.close(); } }