結果

問題 No.265 数学のテスト
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-07 23:19:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,575 bytes
コンパイル時間 4,686 ms
コンパイル使用メモリ 87,484 KB
実行使用メモリ 59,328 KB
最終ジャッジ日時 2023-09-25 06:22:15
合計ジャッジ時間 12,450 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 212 ms
59,328 KB
testcase_01 AC 213 ms
57,588 KB
testcase_02 WA -
testcase_03 AC 208 ms
58,020 KB
testcase_04 AC 206 ms
58,176 KB
testcase_05 AC 191 ms
56,696 KB
testcase_06 AC 212 ms
58,148 KB
testcase_07 AC 208 ms
56,484 KB
testcase_08 AC 208 ms
56,456 KB
testcase_09 AC 200 ms
58,584 KB
testcase_10 AC 204 ms
58,296 KB
testcase_11 AC 204 ms
56,780 KB
testcase_12 AC 142 ms
56,240 KB
testcase_13 AC 157 ms
56,388 KB
testcase_14 AC 154 ms
56,440 KB
testcase_15 AC 141 ms
56,188 KB
testcase_16 AC 157 ms
56,108 KB
testcase_17 AC 124 ms
56,192 KB
testcase_18 AC 138 ms
55,952 KB
testcase_19 AC 141 ms
55,720 KB
testcase_20 AC 143 ms
56,172 KB
testcase_21 AC 140 ms
56,556 KB
testcase_22 AC 159 ms
56,080 KB
testcase_23 AC 124 ms
56,356 KB
testcase_24 AC 140 ms
56,116 KB
testcase_25 AC 163 ms
56,076 KB
testcase_26 AC 139 ms
56,204 KB
testcase_27 AC 141 ms
56,016 KB
testcase_28 AC 149 ms
56,088 KB
testcase_29 AC 139 ms
56,420 KB
testcase_30 AC 147 ms
56,236 KB
testcase_31 AC 139 ms
56,608 KB
testcase_32 AC 140 ms
56,236 KB
testcase_33 AC 139 ms
55,676 KB
testcase_34 AC 140 ms
55,708 KB
testcase_35 AC 140 ms
56,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class No265 {
	
	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		int d = in.nextInt();
		String s = in.next();
		int[] a = new int[d+1];
		calc(a,s.toCharArray());
		for (int i=0; i<d; i++) {
			out.print(a[i] + " ");
		}
		out.println(a[d]);
	}

	static int ptr = 0;

	static void calc(int[] a, char[] cs) {
		while (ptr < cs.length) {
			if (cs[ptr] == 'd') {
				ptr += 2;
				int[] b = new int[a.length];
				calc(b,cs);
				d(b);
				for (int i=0; i<a.length; i++) {
					a[i] += b[i];
				}
			}else {
				int dim = 0;
				int coe = 1;
				boolean f1 = false;
				boolean f2 = false;
				while (ptr < cs.length && cs[ptr] != '+') {
					if (cs[ptr] == 'x') {
						dim++;
						f1 = true;
					}else if ('1' <= cs[ptr] && cs[ptr] <= '9') {
						coe *= cs[ptr] - '0';
						f1 = true;
					}else if (cs[ptr] == '}') {
						f2 = true;
						break;
					}
					ptr++;
				}
				if (f1) a[dim] += coe;
				if (f2) return;
			}
			
			ptr++;
		}	
	}

	static void d(int[] a) {
		for (int i=0; i<a.length-1; i++) {
			a[i] = a[i+1]*(i+1);
		}
		a[a.length-1] = 0;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}
0