C - Convert to Ones

给你一个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;
}

D - Roman Digits

打表? 问 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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Codeforces Round #493 (Div. 1)

    A. /* 发现每次反转或者消除都会减少一段0 当0只有一段时只能消除 这样判断一下就行 */ #include<cstdio> #include<algorithm> #in ...

  4. 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 ...

  5. 【Codeforces Round #493 (Div. 2) B】Cutting

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...

  6. Codeforces Round #493 (Div. 2) A. Balloons 贪心水题

    由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有 ...

  7. Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律

    题意: 我们在研究罗马数字.罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100.一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关.例如XXXV=35,IXI=12. 现 ...

  8. Codeforces Round #493 (Div. 2) C. Convert to Ones 乱搞_构造_好题

    题意: 给你一个长度为 nnn 的 010101串 ,你有两种操作: 1.将一个子串翻转,花费 XXX 2.将一个子串中的0变成1,1变成0,花费 YYY 求你将这个01串变成全是1的串的最少花费. ...

  9. Codeforces Round #493 (Div. 2) B. Cutting 前缀和优化_动归水题

    不解释,题目过水 Code: #include<cstdio> #include<cmath> #include<algorithm> using namespac ...

随机推荐

  1. w3c JS测试

    到W3c的js测试里面溜达了一圈: 做错了几道题: 外部脚本必须包含<script>标签吗? 否!! 这里的外部脚本是指xx.js这个文件,在文件中写js代码是不需要包含script标签的 ...

  2. k8s使用Glusterfs动态生成pv

    一.环境介绍 [root@k8s-m ~]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4 ...

  3. 利用Python实现“指尖陀螺”,让你释放压力

    前言 利用Python实现“指尖陀螺”,让你释放压力 基本环境配置 版本:Python3 系统:Windows 相关模块:turtle 实现效果 不停点击键盘空格键,这个陀螺会慢慢加速,从而达到一个减 ...

  4. IWMS后台上传文章,嵌入视频,调用优酷通用代码

    <a href="http://player.youku.com/player.php/sid/XODcxNjM3OTYw/v.swf " target="_bla ...

  5. MySQL的FIND_IN_SET()函数

    今天在做项目时,看到了一个从没见过的MySQL函数——FIND_IN_SET(),顿时就产生了浓郁的兴趣,然后就搜了搜,翻了翻. 语法:FIND_IN_SET(str,strlist) 定义: 1. ...

  6. Python——Message控件

    一.messagebox的方法: showerror   : 错误提示对话框 showinfo  :  信息提示对话框 showwarning   : 警告对话框 askokcansel   :确认或 ...

  7. 使用layui 做后台管理界面,在Tab中的链接点击后添加一个新TAB的解决方法

    给链接或按钮  添加 onclick="self.parent.addTab('百度','http://www.baidu.com','icon-add')" 如: <a h ...

  8. 待解决ava.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method)

    java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at ja ...

  9. Civil 3D 2017本地化中VBA程序移植到2018版中

    中国本地化包简直就是一块鸡肋, 但对于某些朋友来说还真离不了: 可惜中国本地化包的推出一直滞后, 在最新版软件出来后1年多, 本地化还不一定能够出来, 即使出来了, 也只能是购买了速博服务的用户才能得 ...

  10. git 回退版本

    回滚到指定的版本 git reset --hard e377f60e28c8b84158 强制提交 git push -f origin master