結果
問題 | No.265 数学のテスト |
ユーザー |
|
提出日時 | 2015-08-07 23:14:46 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 288 ms / 2,000 ms |
コード長 | 1,307 bytes |
コンパイル時間 | 4,537 ms |
コンパイル使用メモリ | 78,900 KB |
実行使用メモリ | 55,024 KB |
最終ジャッジ日時 | 2024-11-24 11:22:48 |
合計ジャッジ時間 | 9,314 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
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();long[] a = new long[d + 1];long 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();}}