結果

問題 No.265 数学のテスト
ユーザー syoken_desukasyoken_desuka
提出日時 2015-08-07 23:27:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,845 bytes
コンパイル時間 1,163 ms
コンパイル使用メモリ 145,240 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 06:24:49
合計ジャッジ時間 2,526 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
//諸機能
#pragma region MACRO
#define ANSWER(x) cerr << "answer: "; cout << (x) << endl
#define DOUBLE_ANSWER(x) cerr << "answer: "; cout << set_presicion(10) << (x) << endl
#define END return 0;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a) begin((a)),end((a))
#define FILL(a,n) for(auto &hoge : (a)) hoge = (n)
#define FILL_NDIM_ARRAY(arr,size,val) fill(*(arr),(*(arr) + (size)),(val))
#define mp make_pair
#define EXIST(container, n) ((container).find((n)) != (container).end())
#define STOI(s,i,l) stoi(SUBSTR(s,i,l))
#define SUBSTR(s,i,l) string((s), (i), (l))
#define NPI_TO_RAD(x) (180.0*x/PI)
#define RAD_TO_NPI(x) (PI/180.0*x)
#pragma endregion
//デバッグなどの支援
#pragma region CODING_SUPPORT
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
#pragma endregion
//typedef(書き換える、書き足す可能性ある)
#pragma region TYPE_DEF
typedef long long ll; 
typedef pair<int,int> pii;
typedef pair<string,string> pss;
typedef pair<int,string>pis;
typedef pair<string,int>psi;
typedef vector<string> vs;
typedef vector<int> vi;
#pragma endregion
//諸々の定数(書き換える可能性ある)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (1e9 + 7)
#pragma endregion

long hoge[10][10];
int main()
{
	int n;
	int d;
	string s;
	cin >> n >> d >> s;
	FILL_NDIM_ARRAY(hoge, 100, 0);
	int keisu = 0;
	int d_counta = 0;
	int x_counta = 0;
	// init
	// x_counta = 0;
	// keisu = 1;
	rep(i, s.length())
	{
		if (s[i] == 'd')
		{
			if(i != 0)if (d_counta <= 10)	hoge[d_counta][x_counta] += keisu;
			x_counta = 0;
			keisu = 0;
			d_counta++;
		}
		else if (s[i] == '}')
		{
			if (d_counta <= 10)	hoge[d_counta][x_counta] += keisu;
		    x_counta = 0;
			keisu = 0;
			d_counta--;
		}
		else if (isdigit(s[i]))
		{
			if (keisu == 0)
			{
				keisu = 1;
			}
			keisu *= s[i] - '0';

		}
		else if (s[i] == 'x')
		{
			if (keisu == 0)
			{
				keisu = 1;
			}
			x_counta++;
		}
		else if (s[i] == '+')
		{
			if (s[i - 1] != '}')
			{
				if (d_counta <= 10)	 hoge[d_counta][x_counta] += keisu;
			}
			x_counta = 0;
			keisu = 0;
		}
	}
	if (!s[s.length()-1] != '}')
	{
		if (d_counta <= 10) hoge[d_counta][x_counta] += keisu;
	}
	for (int i = 10-1; i > 0; i--)
	{
		for (int j = 10-1; j > 0; j--)
		{
			hoge[i - 1][j - 1] += j*hoge[i][j];
		}
	}
	for (int i = 0; i < d; i++)
	{
		cout << hoge[0][i] << " ";
	}
	cout << hoge[0][d] << endl;
	return 0;
}

0