結果

問題 No.265 数学のテスト
ユーザー GrenacheGrenache
提出日時 2015-08-07 23:14:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 3,759 ms
コンパイル使用メモリ 78,704 KB
実行使用メモリ 42,532 KB
最終ジャッジ日時 2024-05-03 11:49:22
合計ジャッジ時間 9,859 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 186 ms
42,408 KB
testcase_01 AC 315 ms
42,484 KB
testcase_02 AC 189 ms
42,532 KB
testcase_03 AC 148 ms
41,652 KB
testcase_04 AC 149 ms
40,752 KB
testcase_05 AC 165 ms
41,716 KB
testcase_06 AC 151 ms
40,764 KB
testcase_07 AC 172 ms
41,580 KB
testcase_08 AC 185 ms
42,140 KB
testcase_09 AC 155 ms
41,516 KB
testcase_10 AC 165 ms
41,884 KB
testcase_11 AC 171 ms
41,776 KB
testcase_12 AC 119 ms
41,260 KB
testcase_13 AC 148 ms
41,336 KB
testcase_14 AC 142 ms
41,504 KB
testcase_15 AC 128 ms
41,496 KB
testcase_16 AC 143 ms
41,488 KB
testcase_17 AC 129 ms
41,212 KB
testcase_18 AC 127 ms
41,180 KB
testcase_19 AC 117 ms
41,256 KB
testcase_20 AC 131 ms
41,224 KB
testcase_21 AC 113 ms
39,452 KB
testcase_22 AC 143 ms
40,852 KB
testcase_23 AC 111 ms
41,276 KB
testcase_24 AC 125 ms
41,196 KB
testcase_25 AC 137 ms
41,484 KB
testcase_26 AC 114 ms
40,932 KB
testcase_27 AC 129 ms
41,128 KB
testcase_28 AC 136 ms
41,092 KB
testcase_29 AC 120 ms
40,000 KB
testcase_30 AC 134 ms
41,648 KB
testcase_31 AC 119 ms
39,996 KB
testcase_32 AC 115 ms
41,156 KB
testcase_33 AC 119 ms
39,896 KB
testcase_34 AC 127 ms
41,136 KB
testcase_35 AC 128 ms
41,212 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