[luoguP1981] 表达式求值(U?ェ?*U)


传送门

弄两个栈,一个存数,一个存运算符,然后乱搞。

代码

#include <cstdio> #include <cstring> #include <iostream> #define N 1000001 int n, top_d, top_f; int stack_d[N]; char s[N], stack_f[N]; bool b[N]; int main() stack_d[++top_d] = x; stack_f[++top_f] = s[i]; i++; while(i <= n) stack_d[++top_d] = x; if(stack_f[top_f] == '*') stack_f[++top_f] = s[i]; i++; } for(i = 1; i <= top_d; i++) stack_d[i] = (stack_d[i] + stack_d[i 1]) % 10000; printf("%d\n", stack_d[top_d]); return 0; }

  



上一篇:[luoguP1026] 统计单词个数(DP)

下一篇:[HDU2089] 不要62 (数位DP)


模拟
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图