Codeforces Round #493 (Div. 2)
给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价
两种可能 一种把1全部放到一边 然后把剩下的0变成1 要么把所有的 0 直接变成1
#include<bits/stdc++.h> using namespace std; #define LL long long int main(){ LL n,x,y; string a; cin>>n>>x>>y>>a; ; LL s=,s1=; ;j<a.size();j++){ '&&fa) continue; ){ s++; fa=; }; } LL l=a.size(); LL ans=; ]==]=='){ s1=s+; ans=x*s; }]==]==]==]=='){ s1=s; ans=x*(max(1LL*,s-)); }]==]=='){ s1=max(1LL*,s-); ans=x*(max(1LL*,s-)); } ans+=y; ans=min(ans,y*s1); cout<<ans<<endl; }
打表? 问 n个字符 能组成几个数
#include<bits/stdc++.h> using namespace std; #define LL long long ]={,,,,,,,,,,,}; int main() { LL n; scanf("%lld",&n); ) printf("%d\n",ans[n]); +(n-)*); ; }
Codeforces Round #493 (Div. 2)的更多相关文章
- Codeforces Round #493 (Div 2) (A~E)
目录 Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars(容斥 计数) C ...
- Cutting Codeforces Round #493 (Div. 2)
Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you ...
- Codeforces Round #493 (Div. 1)
A. /* 发现每次反转或者消除都会减少一段0 当0只有一段时只能消除 这样判断一下就行 */ #include<cstdio> #include<algorithm> #in ...
- Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目
D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 【Codeforces Round #493 (Div. 2) B】Cutting
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...
- Codeforces Round #493 (Div. 2) A. Balloons 贪心水题
由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有 ...
- Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律
题意: 我们在研究罗马数字.罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100.一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关.例如XXXV=35,IXI=12. 现 ...
- Codeforces Round #493 (Div. 2) C. Convert to Ones 乱搞_构造_好题
题意: 给你一个长度为 nnn 的 010101串 ,你有两种操作: 1.将一个子串翻转,花费 XXX 2.将一个子串中的0变成1,1变成0,花费 YYY 求你将这个01串变成全是1的串的最少花费. ...
- Codeforces Round #493 (Div. 2) B. Cutting 前缀和优化_动归水题
不解释,题目过水 Code: #include<cstdio> #include<cmath> #include<algorithm> using namespac ...
随机推荐
- .Net MVC4 log4net的配置
一.首先在使用log4net记录日志的时候,我们要引用log4net.dll文件 二.在web.config中添加一下配置代码 <configSections> <!-- For m ...
- Eclipse导入工程后出现中文乱码
Eclipse之所以会出现乱码问题是因为eclipse编辑器选择的编码规则是可变的.一般默认都是UTF-8或者GBK,当从外部导入的一个工程时,如果该工程的编码方式与eclipse中设置的编码方式不同 ...
- 剑指offer(4)
题目: 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字.例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2 ...
- git上传本地代码到github
1.(先进入项目文件夹)通过命令 git init 把这个目录变成git可以管理的仓库 git init 2.把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小 ...
- kubernetes资源类别介绍
类别 名称 资源对象 Pod.ReplicaSet.ReplicationController.Deployment.StatefulSet.DaemonSet.Job.CronJob.Horizon ...
- mysql 数据库的主从同步
1.复制准备 操作系统 centOS 主库(mysql master): ip为123.56.94.1 port为3306 mysql 版本 5.7.16 从库(mysql slave): ...
- webpack安裝和卸載
webpack安裝和卸載 安裝: 先裝好node和npm: 安裝package.json:進入到根目錄,運行npm init 新建全局webpack:cd退到全局目錄,運行npm install -g ...
- vue-resource: jsonp请求百度搜索的接口
1. yarn add vue-resource 2. main.js引入vue-resource import Vue from 'vue' import MintUI from 'mint-ui' ...
- 洛谷 P1141 01迷宫
看似普通的 bfs 题(实际上也不怎么难 主要是我太菜了) 题目链接:https://www.luogu.org/problemnew/show/P1141 如果直接用简单的bfs一顿求的话,会超时( ...
- How to mount HFS EFI on macOS
mount_hfs /dev/disk0s1 /volumes/efi