zoj 3829 Known Notation】的更多相关文章

作者:jostree 转载请说明出处 http://www.cnblogs.com/jostree/p/4020792.html 题目链接: zoj 3829 Known Notation 使用贪心+模拟.由于没有数字之间没有空格,因此该题有如下性质: 1.如果该字符串全部为数字,则无需操作,直接输出0. 2.连续的n个数字后面接连续的m个*,当n>m时,一定是有效的答案.从而最终的目的就是把最后的数字尽量向前移动,把最前面非法的*尽量向后移动,因此insert操作添加数字时,只需添加在最前面即…
题目传送门 /* 题意:一串字符串,问要最少操作数使得成为合法的后缀表达式 贪心+模拟:数字个数 >= *个数+1 所以若数字少了先补上在前面,然后把不合法的*和最后的数字交换,记录次数 岛娘的代码实在难懂啊~ */ /************************************************ * Author :Running_Time * Created Time :2015-8-16 14:29:49 * File Name :K.cpp **************…
Known Notation Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 Description Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathematics and computer science…
主题链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=5383 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.…
乱搞: 1.数字的个数要比*的个数多一个,假设数字不足须要先把数字补满 2.最优的结构应该是数字都在左边,*都在右边 3.从左往右扫一遍,遇到数字+1,遇到*-1,假设当前值<1则把这个*和最后面的一个数字交换位置 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…
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 known as postfix notation since every operator in an expre…
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 is also known as postfix notation since every operator in an expres…
Description 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 all of its operands. Bob is a student in…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 给定一个字符串(只包含数字和星号)可以在字符串的任意位置添加一个数字,还可以交换任意两个字符,问需要多少步能得到一个合法后缀表达式. 如果数字<星号+1 那么必须要添加数字,那么肯定是添加在字符串前面是最优的,然后从头到尾扫描整个串,如果遇到星号并且前面出现的数字>=2 数字减1,否则就要从后往前找第一个非*的数字然后与星号交换. 注意全为数字的情况,和处理完后字…
题目链接:problemId=5383">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5383 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 ever…