博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
K - Known Notation ZOJ - 3829 贪心
阅读量:4205 次
发布时间:2019-05-26

本文共 707 字,大约阅读时间需要 2 分钟。

题意:给两种操作:

(1)在表达式中填1;

(2)交换任意两个元素;

要求用最少的操作使字符串构成逆波兰表达式。

思路:贪心。

(1)先让numof(*)==numof(1)-1;

(2)从前往后扫,如果遇到*,numof(*)++;

else numof(1)++;

if numof(*)>=numof(1)   需要把后边的数字交换到前边的*,

即numof(*)--;

numof(1)++;

op++;

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define lowbit(x) (x&-x)#define e exp(1.0)//ios::sync_with_stdio(false);typedef long long ll;typedef long long LL;using namespace std;int main(){ int T; ios::sync_with_stdio(false); cin>>T; string s; while(T--) { cin>>s; int num = 0,starnum = 0; for(int i=0;i
=num) { ans++; starnum--; num++; } } cout<
<

转载地址:http://nlali.baihongyu.com/

你可能感兴趣的文章
Android编译系统环境初始化过程分析
查看>>
user2eng 笔记
查看>>
DRM in Android
查看>>
ARC MRC 变换
查看>>
Swift cell的自适应高度
查看>>
【linux】.fuse_hiddenXXXX 文件是如何生成的?
查看>>
【LKM】整合多个LKM为1个
查看>>
【Kernel】内核热补丁技术揭秘
查看>>
【Error】/usr/bin/env: ‘python’: No such file or directory
查看>>
手工挂载VMware共享目录
查看>>
【Kernel】pid 与 tgid
查看>>
【Error】make LKM时 找不到符号
查看>>
【转载】【C语言】浅析C语言之uint8_t / uint16_t / uint32_t /uint64_t
查看>>
【转载】yum update 自动忽略内核更新
查看>>
【maven】打包jar上传到服务器运行
查看>>
关闭centos wayland
查看>>
【Error】chsh: PAM: Authentication failure
查看>>
【Error】zsh历史记录丢失
查看>>
解析漏洞总结
查看>>
有趣的二进制 读书笔记
查看>>