結果

問題 No.265 数学のテスト
ユーザー mikoto1357mikoto1357
提出日時 2015-08-07 22:50:38
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,015 bytes
コンパイル時間 3,378 ms
コンパイル使用メモリ 76,008 KB
実行使用メモリ 59,696 KB
最終ジャッジ日時 2023-09-25 06:09:26
合計ジャッジ時間 10,467 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
54,232 KB
testcase_01 AC 333 ms
57,608 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 AC 137 ms
56,032 KB
testcase_18 AC 139 ms
56,068 KB
testcase_19 RE -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 AC 136 ms
56,204 KB
testcase_24 RE -
testcase_25 WA -
testcase_26 RE -
testcase_27 WA -
testcase_28 WA -
testcase_29 RE -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 136 ms
56,048 KB
testcase_33 AC 135 ms
56,352 KB
testcase_34 AC 136 ms
55,596 KB
testcase_35 AC 137 ms
55,984 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) == 'x'){
						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