Codeforces Round #493 (Div. 1)
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)的更多相关文章
- 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. 2)
C - Convert to Ones 给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价 两种可能 一种把1全部放到一边 然后把剩下的0变成1 要么把所有的 ...
- 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 ...
随机推荐
- 使用.pth文件扩展python环境路径
使用.pth文件扩展python环境路径 有时候我们不希望把一个库放到 site-packages 下面,而是更愿意把它保留在原始的工程目录中,方便管理和维护.那么怎么能让 Python 运行环境找到 ...
- pyhanlp 共性分析与短语提取内容详解
pyhanlp 共性分析与短语提取内容详解 简介 HanLP中的词语提取是基于互信息与信息熵.想要计算互信息与信息熵有限要做的是 文本分词进行共性分析.在作者的原文中,有几个问题,为了便于说明,这 ...
- ionic platform add ios, Error:spawn EACCES
RT: cordova ionic 环境搭建好之后,需要添加平台才能打包,添加平台如果出错:Error:spawn EACCES, 原因是因为没添加hooks, 请使用 ionic add hooks ...
- oracle rac的启动与停止
引言:这写篇文章的出处是因为我的一名学生最近在公司搭建RAC集群,但对其启动与关闭的顺序和原理不是特别清晰,我在教学工作中也发现了很多学员对RAC知识了解甚少,因此我在这里就把RAC里面涉及到的最常用 ...
- 让Delphi XE5跟其他版本的Delphi共存 [转]
找到Delphi XE5的安装根目录 .... \Program Files (x86)\Embarcadero\RAD Studio\12.0\bin下的cglm.ini文件, 打开cglm.i ...
- 黑域,黑阈 Permission denied
在执行: adb -d shell sh /data/data/me.piebridge.brevent/brevent.sh 时遇到Permission denied,多运行一次就好了. 完整的有两 ...
- sql中的STRFTIME
STRFTIME返回的是一个字符串 STRFTIME('%w',myTime) in ('1','2','4','5') 可以正确执行,而 STRFTIME('%w',myTime) in (1,2, ...
- PrintWriter中的write与println方法居然就是这些区别
为什么循环中分别用write方法和println方法效果一样呢? import java.io.*; public class WriteLog { private BufferedReader bf ...
- 【maven】之打包不带版本号的问题
今天在写maven项目的时候发现打包没有带版本号,只有包名 百思不得其解,我翻看之前的项目发现并没有这种情况,最后看了一下文档 发现是自己在build中写了fileName 导致的!删除自定义的fi ...
- JIRA 资源
https://www.**.com/article/2015/8/7/22532.html e_v_g_e_t JIRA使用教程:在Windows上安装JIRAJIRA使用教程:在Linux上安装J ...