CodeForces Round #553 Div2
A. Maxim and Biology
代码:
#include <bits/stdc++.h>
using namespace std; int N;
string s;
int minn = 0x3f3f3f3f; int main() {
scanf("%d", &N);
cin >> s;
for(int i = ; i <= N - ; i ++) {
int cnt = ;
for(int j = i; j < i + ; j ++) {
if(j == i) {
if(s[j] == 'Z') cnt += ;
else cnt += min(s[j] - 'A', ('Z' - s[j] + ));
}
if(j == i + ) cnt += min(abs(s[j] - 'C'), ('Z' - s[j] + ));
if(j == i + ) cnt += min(abs(s[j] - 'T'), (s[j] - 'A' + ));
if(j == i + ) cnt += min(abs(s[j] - 'G'), ('Z' - s[j] + ));
}
minn = min(minn, cnt);
}
printf("%d\n", minn);
return ;
} /*
9
AAABBBCCC
*/
C. Problem for Nazar
代码:
#include <bits/stdc++.h>
using namespace std; const int mod = 1e9 + ;
long long l, r; long long sum(long long x) {
if(x <= ) return ;
int flag = ;
long long t = ;
long long sum1 = , sum2 = ;
for(long long i = ; i < x; ) {
long long nx = min(i + t, x);
if(flag) sum1 += (nx - i);
else sum2 += (nx - i); t *= ;
i = nx;
flag ^= ;
}
long long ans = sum2 % mod * ((sum2 + ) % mod) % mod + sum1 % mod * (sum1 % mod) % mod;
return ans % mod;
} int main() {
cin >> l >> r;
cout << (sum(r) - sum(l - ) + mod) % mod << endl; return ;
}
D. Stas and the Queue at the Buffet
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
int N; struct Node {
long long a;
long long b;
}node[maxn]; bool cmp(const Node &n, const Node &m) {
return (n.a - n.b) > (m.a - m.b);
} int main() {
scanf("%d", &N);
for(int i = ; i <= N; i ++)
cin >> node[i].a >> node[i].b; sort(node + , node + + N, cmp);
long long ans = ;
for(int i = ; i <= N; i ++)
ans += (node[i].a * (i - ) + node[i].b * (N - i)); cout << ans << endl; return ;
}
E. Number of Components
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
int N;
long long a[maxn]; int main() {
scanf("%d", &N);
for(int i = ; i <= N; i ++)
cin >> a[i]; long long ans = ;
for(int i = ; i <= N; i ++) {
if(a[i] > a[i - ])
ans += (a[i] - a[i - ]) * (N - a[i] + );
else if(a[i] != a[i - ])
ans += (a[i - ] - a[i]) * a[i];
} cout << ans << endl; return ;
}
CodeForces Round #553 Div2的更多相关文章
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round #564(div2)
Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...
- Codeforces Round #361 div2
ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...
- Codeforces Round #626 Div2 D,E
比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...
- CodeForces Round 192 Div2
This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
- Codeforces Round #360 div2
Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...
随机推荐
- Python批量修改寄存器的值
在写代码过程中,我们修改代码中寄存器的值,但是有时寄存器的数据较多,手动修改容易出现错误而且花费的时间长 这是一段寄存器的配置值: 0x00, 0x34 0x35, 0x25 0x10, 0xd4 ...
- JQuery官方学习资料(译):Utility方法
JQuery提供了一些utility方法在$命名空间里,这些方法对完成常规的编程任务非常有帮助. $.trim() 删除前后部的空白内容. // 返回 "lots of ex ...
- XML记一次带命名空间的xml读取
public static void ReadXML(string xmlUrl) { //判断文件是否存在 if (!File.Exists(xmlUrl)) { Console.WriteLine ...
- [MySQL] explain中的using where和using index
1. 查看表中的所有索引 show index from modify_passwd_log; 有两个 一个是id的主键索引 , 一个是email_id的普通索引 2. using index表示 ...
- Elasticsearch系列(5):深入搜索
结构化搜索 结构化搜索是指搜索那些具有内置结构数据的过程,比如日期,时间和数字都是结构化的,它们有精确的格式,我们可以对这些格式进行逻辑操作,比较常见的操作包括比较数字或时间的范围,或判定两个值的大小 ...
- Spring(二)继承jdbcDaoSupport的方式实现(增删改查)
一 首先创建数据库表和相应的字段,并创建约束 二 建立项目,导入jar包(ioc,aop,dao,数据库驱动,连接池)并且将applicationContext.xml文件放在src下 三 开启组件扫 ...
- 字符串hash入门
简单介绍一下字符串hash 相信大家对于hash都不陌生 翻译过来就是搞砸,乱搞的意思嘛 hash算法广泛应用于计算机的各类领域,像什么md5,文件效验,磁力链接 等等都会用到hash算法 在信息学奥 ...
- SQL Challenges
平台: http://www.zixem.altervista.org/SQLi/ Level 1 (Super Easy) http://www.zixem.altervista.org/SQLi/ ...
- Access denied for user 'root'@'localhost' (using password:YES) Mysql5.7
解决方案: (1) 打开MySQL目录下的my.ini文件,在文件的最后添加一行“skip-grant-tables”,保存并关闭文件.(my.ini在C:\ProgramData\MySQL\MyS ...
- Android使用Mob ShareSDK 分享不同平台
Share分享,要注意的是,如果不能调用起微信相关,看看微信开发者平台是否添加正式,微信开发者正式之后,打正式包进行分享调用 /*分享弹框*/ private void showShare2() { ...