結果

問題 No.49 算数の宿題
ユーザー nksk38
提出日時 2017-07-23 23:32:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 877 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 83,872 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 01:57:52
合計ジャッジ時間 1,234 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

set<string> s;

int main()
{
	string s,str="";  cin >> s;

	ll num = 0,ans=0;
	char ope = '*';
	for (int i = 0; i < s.size(); i++) {
		if (s[i] >= '0' && s[i] <= '9') {
			str += s[i];
		}
		if (s[i] < '0' || s[i] > '9' || (i == s.size() - 1)) {
			if (ope == '+') {
				ans = ans * stoll(str);
			}
			else if (ope == '*') {
				ans = ans + stoll(str);
			}
			ope = s[i];
			num = stoll(str);
			str = "";
		}
	}
	cout << ans << endl;
	return	0;
}
0