A.

/*
发现每次反转或者消除都会减少一段0
当0只有一段时只能消除
这样判断一下就行 */ #include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#define M 300010
#define ll long long using namespace std;
int read() {
int nm = , f = ;
char c = getchar();
for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
for(; isdigit(c); c = getchar()) nm = nm * + c - '';
return nm * f;
}
ll n,x,y;
char s[M];
int main() {
n = read(), x = read(), y = read();
scanf("%s", s + );
int len = strlen(s + );
s[] = '?';
ll tot = ;
for(int i = ; i <= len; i++) if(s[i] != s[i - ] && s[i] == '') tot++;
if(tot == ) return puts("");
cout << min(tot * y, tot * x - x + y);
return ;
}

B.

/*
可能这种题是打表克星
小数据部分没有规律 数据大了有规律 //一个显然的结论 ,如果数字总数确定的话我们求 1, 5, 10, 50 加起来的不同和的个数相当于求0, 4, 9, 49 的
好吧打打表就出来了
对于前12的数据 直接暴力 ,后面的线性增加  */ #include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#define M 30
#define ll long long using namespace std;
int read() {
int nm = , f = ;
char c = getchar();
for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
for(; isdigit(c); c = getchar()) nm = nm * + c - '';
return nm * f;
}
const ll dx[]={,,,,,,,,,,,,,,,};
int main() {
ll n = read();
if(n <= ) cout << dx[n];
else cout << dx[] + (n - ) * ;
return ;
}

C.

显然同色的一行在哪一行对答案贡献是一样的,于是我们可以直接得出容斥的式子

/*
difficult 看题解啦 */ #include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#define M 1231231
#define ll long long
const int mod = ;
using namespace std;
int read() {
int nm = , f = ;
char c = getchar();
for(; !isdigit(c); c = getchar()) if(c == '-') f = -;
for(; isdigit(c); c = getchar()) nm = nm * + c - '';
return nm * f;
}
ll poww(ll a, ll b) {
ll as = , tmp = a;
for(; b; b >>= , tmp = tmp * tmp % mod) if(b & ) as = as * tmp % mod;
return as;
}
ll c[M]; inline ll ni(ll a) {
return poww(a, mod - );
}
void shai(ll n) {
c[] = ;
for(int i = ; i <= n; i++) c[i] = c[i - ] * (n - i + ) % mod * ni(i) % mod;
}
int main() {
ll n = read();
ll ans = ;
shai(n);
for(int i = , j = ; i <= n; i++, j = -j) ans += j * c[i] % mod * poww(, (n - i) * n + i) % mod, ans %= mod;
ans = ans * % mod;
for(int i = , j = -; i < n; i++, j = -j) ans += 3ll * c[i] * j % mod * (poww(1ll - poww(, i), n) - poww(-1ll * poww(3ll, i), n)) % mod, ans %= mod;
cout << (ans + mod) % mod;
return ;
}

Codeforces Round #493 (Div. 1)的更多相关文章

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

    C - Convert to Ones 给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价 两种可能 一种把1全部放到一边 然后把剩下的0变成1  要么把所有的 ...

  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. VS2010生成安装包制作步骤 (转)

    阅读目录 VS2010生成安装包制作步骤 回到目录 VS2010生成安装包制作步骤   在VS2010中文旗舰版本中生成winForm安装包,可以复制你电脑中的开发环境,避免你忘记了一下配置然后在别的 ...

  2. Zookeeper基本数据模型

    一.Zookeeper基本数据模型 是一个树形结构,类似于前端开发中的tree.js组件 zk的数据模型也可以理解为linux/unix的文件目录  /usr/local/... 每一个节点称之为zn ...

  3. Linux split命令详解

    Linux split命令 Linux split命令用于将一个文件分割成数个.该指令将大文件分割成较小的文件,在默认情况下将按照每1000行切割成一个小文件. 将输入内容拆分为固定大小的分片并输出到 ...

  4. Spring Cloud(Dalston.SR5)--Hystrix 断路器-合并请求

    在 Spring Cloud 中可以使用注解的方式来支持 Hystrix 的合并请求,缓存与合并请求功能需要先初始化请求上下文才能实现,因此,必须实现 javax.servlet.Filter 用于创 ...

  5. Maya中输出nuke脚本的方法

    因项目需要,三维部门跟踪组动画组都需要一个能够快速输出nuke预合成工程的脚本.脚本已经写完,源码不便于放出来,写一个大致思路吧. 我首先分析了nuke工程,内部包含了哪些节点,这些节点有哪些属性需要 ...

  6. py2exe 打包的两种方式

    cmd模式 #!/usr/bin/python #-*- coding: UTF-8 -*- from distutils.core import setup import py2exe setup( ...

  7. linux的系统组成和计算机组成原理,linux常用操作

    Linux入门 linux简介   学习目的:linux服务器操作系统稳定长期运行,python,pycharm装于linux上 linux系统组成 应用软件:调用系统软件接口 linux操作系统分两 ...

  8. Excel导出文件流下载

    Controller.cs @CrossOrigin(allowCredentials="true", allowedHeaders="*", methods= ...

  9. 服务容错保护断路器Hystrix之二:Hystrix工作流程解析

    一.总运行流程 当你发出请求后,hystrix是这么运行的 红圈 :Hystrix 命令执行失败,执行回退逻辑.也就是大家经常在文章中看到的“服务降级”. 绿圈 :四种情况会触发失败回退逻辑( fal ...

  10. 事件之onTouch方法的执行过程 及和 onClick执行发生冲突的解决办法

    转载:http://blog.csdn.net/jiangwei0910410003/article/details/17504315#quote 博主推荐: 风萧兮兮易水寒,“天真”一去兮不复还.如 ...