結果

問題 No.265 数学のテスト
ユーザー GrenacheGrenache
提出日時 2015-08-07 23:14:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 3,801 ms
コンパイル使用メモリ 76,316 KB
実行使用メモリ 56,840 KB
最終ジャッジ日時 2023-08-16 02:01:57
合計ジャッジ時間 10,938 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
56,172 KB
testcase_01 AC 316 ms
56,712 KB
testcase_02 AC 185 ms
56,756 KB
testcase_03 AC 161 ms
55,928 KB
testcase_04 AC 162 ms
55,580 KB
testcase_05 AC 184 ms
56,408 KB
testcase_06 AC 161 ms
55,548 KB
testcase_07 AC 182 ms
56,500 KB
testcase_08 AC 182 ms
56,840 KB
testcase_09 AC 153 ms
55,824 KB
testcase_10 AC 155 ms
56,040 KB
testcase_11 AC 187 ms
56,804 KB
testcase_12 AC 132 ms
55,844 KB
testcase_13 AC 145 ms
56,308 KB
testcase_14 AC 142 ms
56,136 KB
testcase_15 AC 127 ms
56,096 KB
testcase_16 AC 141 ms
56,252 KB
testcase_17 AC 126 ms
55,892 KB
testcase_18 AC 126 ms
56,036 KB
testcase_19 AC 128 ms
56,128 KB
testcase_20 AC 130 ms
56,072 KB
testcase_21 AC 126 ms
55,748 KB
testcase_22 AC 145 ms
55,740 KB
testcase_23 AC 127 ms
55,808 KB
testcase_24 AC 127 ms
56,012 KB
testcase_25 AC 148 ms
56,228 KB
testcase_26 AC 127 ms
56,048 KB
testcase_27 AC 125 ms
55,720 KB
testcase_28 AC 132 ms
56,192 KB
testcase_29 AC 129 ms
56,084 KB
testcase_30 AC 136 ms
55,692 KB
testcase_31 AC 125 ms
55,708 KB
testcase_32 AC 124 ms
55,900 KB
testcase_33 AC 125 ms
56,124 KB
testcase_34 AC 127 ms
56,340 KB
testcase_35 AC 125 ms
55,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
}
0