uva-11234 Expressions】的更多相关文章

题目给出一个后缀表达式,让你求从下往上的层次遍历. 思路:结构体建树,然后用数组进行BFS进行层次遍历,最后把数组倒着输出就行了. uva过了,poj老是超时,郁闷. 代码: #include <cstdio> #include <cstring> #include <cstdlib> const int maxn = 10001; char str[maxn]; int p; struct Node { char data; Node* l; Node* r; };…
画图出来后结果很明显 xyPzwIM abcABdefgCDEF sample output wzyxIPM gfCecbDdAaEBF * + - x y z w F B E a A d D b c e C f g #include<cstdio> #include<cstring> #include<iostream> #include<string> #include<algorithm> #include<stack> #in…
找最长的连接的点的数量.用tarjan缩点,思考可知每一个强连通分量里的点要么都选,要么都不选(走别的路),可以动规解决. #include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<cstring> using namespace std; ; int top,stack[mxn]; bool inst[mxn]; int cnt,dnow;…
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes…
127 - "Accordian" Patience 题目大意:一个人一张张发牌,如果这张牌与这张牌前面的一张或者前面的第三张(后面称之为一位置和三位置)的点数或花式相同,则将这张牌移动到与之对应的位置(优先三位置,也就是说如果一位置与三位置都有以上的性质则移动到三位置之上),移动之后若仍以上的性质,则继续操作,直到已发的所有牌都无法移动之后再继续发牌,(如果一个位置被移空,则删除此位置!) 解题思路:用数组模拟链表,每发一张牌就匹配三位置,如果匹配就移动,否则再看一位置是否满足,如果…
Evaluating Simple C Expressions The task in this problem is to evaluate a sequence of simple C expressions, buy you need not know C to solve the problem! Each of the expressions will appear on a line by itself and will contain no more than 110 charac…
 Evaluating Simple C Expressions  The task in this problem is to evaluate a sequence of simple C expressions, buy you need not know C to solve the problem! Each of the expressions will appear on a line by itself and will contain no more than 110 char…
由于没有括号,只有+,-,++,--,优先级简单,所以处理起来很简单. 题目要求计算表达式的值以及涉及到的变量的值. 我这题使用stl的string进行实现,随便进行练手,用string的erase删掉全部空格,然后对++.--进行处理然后删去,最后就只剩简单式子了,简单循环下就出来了. 这里有几个坑点: 1.erase函数删除字符后,后面字符的下标都会发生变化,刚开始使用i++去检查空格,结果删除后会跳掉字符. 2.++.--的后缀处理要注意,我开了两个数组放后缀运算的. 3.输出的变量值是当…
题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=48 Tree Summing  Background LISP was one of the earliest high-level programming languages and, with FORTRAN, is one of the olde…
Matrix Chain Multiplication Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVA 442 Appoint description:  System Crawler  (2015-08-25) Description   Suppose you have to evaluate an expression like A*B*C*D…