結果

問題 No.708 (+ー)の式
ユーザー aguroshouaguroshou
提出日時 2018-06-30 00:18:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,537 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 70,488 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 15:54:33
合計ジャッジ時間 1,429 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	//long long n, A[1000000000];
	string s;
	cin >> s;
	/*for ( a = s.length()-1; a >= 0; a--)
	{

	}*/
	int num[101];
	for (a = 0; a < s.length(); a++)
	{
		if (s[a] == '1')
		{
			num[a] = 1;
		}
		else if (s[a] == '2')
		{
			num[a] = 2;
		}
		else if (s[a] == '3')
		{
			num[a] = 3;
		}
		else if (s[a] == '4')
		{
			num[a] = 4;
		}
		else if (s[a] == '5')
		{
			num[a] = 5;
		}
		else if (s[a] == '6')
		{
			num[a] = 6;
		}
		else if (s[a] == '7')
		{
			num[a] = 7;
		}
		else if (s[a] == '8')
		{
			num[a] = 8;
		}
		else if (s[a] == '9')
		{
			num[a] = 9;
		}
	}
	for (a = 0; a < s.length(); a++)
	{
		if (s[a] == '-'&&s[a + 1] != '(')
		{
			a++;
			num[a] *= -1;
		}

	}
	for (a = 0; a < s.length(); a++)
	{
		if (s[a] == '-'&&s[a + 1] == '(')
		{
			a += 2;
			while (!(s[a] == ')'))
			{
				if (num[a] >= -9 && num[a] <= 9)
				{

				num[a] *= -1;
				}
				a++;
			}
		}

	}
	b = 0;
	for (a = 0; a < s.length(); a++)
	{
		if (num[a]>=-9&&num[a]<=9)
		{
			b += num[a];
			//cout << num[a] << endl;

		}
	}
	/*for (a = 0; a < s.length(); a++)
	{
		cout << s[a] << endl;
	}*/
	cout << b << endl;
	return 0;
}
0