結果

問題 No.265 数学のテスト
ユーザー mikoto1357mikoto1357
提出日時 2015-08-07 22:57:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,178 bytes
コンパイル時間 4,359 ms
コンパイル使用メモリ 75,408 KB
実行使用メモリ 40,956 KB
最終ジャッジ日時 2023-09-25 06:12:09
合計ジャッジ時間 9,654 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 178 ms
40,112 KB
testcase_01 AC 321 ms
40,924 KB
testcase_02 WA -
testcase_03 AC 166 ms
39,992 KB
testcase_04 AC 164 ms
40,000 KB
testcase_05 RE -
testcase_06 AC 163 ms
40,248 KB
testcase_07 AC 175 ms
40,300 KB
testcase_08 AC 188 ms
40,836 KB
testcase_09 AC 161 ms
39,972 KB
testcase_10 AC 165 ms
40,368 KB
testcase_11 AC 176 ms
40,624 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 152 ms
39,756 KB
testcase_17 AC 132 ms
39,848 KB
testcase_18 AC 135 ms
39,500 KB
testcase_19 RE -
testcase_20 AC 139 ms
39,600 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 135 ms
39,468 KB
testcase_24 RE -
testcase_25 AC 153 ms
39,836 KB
testcase_26 RE -
testcase_27 AC 133 ms
39,640 KB
testcase_28 AC 142 ms
39,580 KB
testcase_29 RE -
testcase_30 AC 139 ms
39,596 KB
testcase_31 RE -
testcase_32 AC 132 ms
39,372 KB
testcase_33 AC 132 ms
39,632 KB
testcase_34 AC 138 ms
39,960 KB
testcase_35 AC 140 ms
40,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int d = scan.nextInt();
		String s = scan.next();
		int[] z = new int[d+1];
		for(int i = 0;i < d;i++)	z[i] = 0;
		int dcount = 0 , zisuu = 0 , suu = 0;
		for(int i = 0;i < n;i++){
			if(s.charAt(i) == 'd'){
				dcount++;
				i++;
			}
			if(s.charAt(i) >= '1' && s.charAt(i) <= '9' || s.charAt(i) == 'x'){
				if(s.charAt(i) >= '1' && s.charAt(i) <= '9'){
					suu = s.charAt(i) - '0';
					zisuu = 0;
				}else{
					suu = 1;
					zisuu = 1;
				}
				if(i + 1 != n){
					while(s.charAt(i+1) == '*' && (s.charAt(i+2) >= '1' && s.charAt(i+2) <= '9' || s.charAt(i+2) == 'x')){
						if(s.charAt(i+2) >= '1' && s.charAt(i+2) <= '9'){
							suu *= s.charAt(i+2) - '0';
						}else{
							zisuu++;
						}
						i += 2;
						if(i == n)	break;
					}
				}
				if(dcount > 0){
					for(int j = dcount;j > 0;j--){
						suu *= zisuu;
						zisuu--;
					}
					if(zisuu < 0)	zisuu = 0;
				}
				z[zisuu] += suu;
			}
			if(s.charAt(i) == '}')	dcount--;
		}
		for(int i = 0;i < d+1;i++){
			System.out.print(z[i] + " ");
		}
	}
}
0