输入一个长度不超过1000的字符串,包括数字(1-9)和星号(*)。字符串中的空格已经丢失,所以连起来的数字串可以看成许多分开的数,也可以看成连续的数,即可以随意添加空格。现在有两种操作:1)在任意位置添加任意类型的字符(数字或者星号) 2)交换字符串中的任意两个字符
求:最少操作多少次,使得得到的串是一个合法的逆波兰式...
分类:
其他好文 时间:
2014-10-13 15:03:19
阅读次数:
208
Known Notation
Time Limit: 2 Seconds Memory Limit: 131072 KB
Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics and computer science. It is also kn...
分类:
其他好文 时间:
2014-10-13 12:54:49
阅读次数:
152
题目链接:zoj 3829 Known Notation
题目大意:给定一个不完整的后缀表达式,要求有2种不同操作,用尽量少的操作使得表达式完整。
解题思路:贪心,数字的个数要要保证比?的个数多1,不够的话优先补在开头是最优的。然后遍历一遍字符串,碰到数字+1,碰到?-1,保证数字的个数大于等1,如果不够减的话,可以和最后面的一个数字交换位置(用栈维护十分方便),因为添加和交换代价都是...
分类:
其他好文 时间:
2014-10-13 12:15:49
阅读次数:
157
ZOJ 3829 Known Notation(字符串处理 数学)2014年ACM/ICPC 亚洲区域赛牡丹江(第一站)现场赛...
分类:
其他好文 时间:
2014-10-12 23:35:08
阅读次数:
321
Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics and computer science. It is also known as postfix notation since every operator in an expression
follows ...
分类:
其他好文 时间:
2014-10-12 22:58:58
阅读次数:
263
Known NotationTime Limit:2 Seconds Memory Limit:65536 KBDo you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics a...
分类:
其他好文 时间:
2014-10-12 22:38:08
阅读次数:
209
题目链接:
Known Notation
Time Limit: 2 Seconds Memory Limit: 65536 KB
Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics and computer science. It...
分类:
其他好文 时间:
2014-10-12 22:26:48
阅读次数:
250
题目链接:zoj 3829 Known Notation作者:jostree 转载请说明出处使用贪心+模拟。由于没有数字之间没有空格,因此该题有如下性质:1.如果该字符串全部为数字,则无需操作,直接输出0。2.连续的n个数字后面接连续的m个*,当n>m时,一定是有效的答案。从而最终的目的就是把最后的...
分类:
其他好文 时间:
2014-10-12 20:53:48
阅读次数:
178
Known Notation
Time Limit: 2 Seconds Memory Limit: 131072 KB
Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics and computer science. It is also kn...
分类:
其他好文 时间:
2014-10-12 18:52:18
阅读次数:
319
POJ 1330 DescriptionA rooted tree is a well-known data structure in computer science and engineering. An example is show...
分类:
其他好文 时间:
2014-10-09 13:40:33
阅读次数:
300