結果

問題 No.265 数学のテスト
ユーザー masamasa
提出日時 2015-08-26 22:37:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 849 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 63,488 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 18:36:14
合計ジャッジ時間 2,641 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, d;
	string s;
	cin >> n >> d >> s;

	int pow_d = 0;
	int pow_x = 0;

	vector<int> ans(d + 1, 0);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'd') {
			pow_d++;
			i++; // {
		} else if (s[i] == '}') {
			pow_d--;
		} else if (isdigit(s[i]) || s[i] == 'x') {
			int a     = isdigit(s[i]) ? s[i] - '0' : 1;
			int pow_x = isdigit(s[i]) ? 0          : 1;
			while (s[i+1] == '*' && s[i+2] == 'x') {
				pow_x++;
				i += 2; // *x
			}

			if (pow_x >= pow_d) {
				for (int i = 0; i < pow_d; i++) {
					a *= pow_x - i;
				}
				ans[pow_x - pow_d] += a;
			}
		}
	}

	for (int i = 0; i < ans.size(); i++) {
		if (i != 0) {
			cout << " ";
		}
		cout << ans[i];
	}
	cout << endl;
	return 0;
}
0