Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
180247 刘睿甫 表达式求值 C++ 通过 100 11 MS 2656 KB 673 2024-08-21 13:04:16

Tests(10/10):


#include <bits/stdc++.h> using namespace std; long long a[100002]; bool b[100001]; int main() { string str; int i, t = 0, top = 0; long long sum = 0; cin >> str; int len = str.size(); for (i = 0; i < len; ++i) if (str[i] == '+') { a[++top] = t; t = 0; } else if (str[i] == '*') { a[++top] = t; t = 0; b[top] = true; } else t = t * 10 + str[i] - '0'; a[++top] = t; for (i = 1; i <= top; ++i) if (b[i]) { a[i + 1] = a[i] * a[i + 1] % 10000; a[i] = 0; } for (i = 1; i <= top; ++i){ sum = (sum + a[i]) % 10000; } cout << sum; return 0; }


测评信息: