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的更多相关文章

  1. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  2. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  3. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  4. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  5. Codeforces Round #361 div2

    ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...

  6. Codeforces Round #626 Div2 D,E

    比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...

  7. CodeForces Round 192 Div2

    This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...

  8. Codeforces Round #359 div2

    Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...

  9. Codeforces Round #360 div2

    Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...

随机推荐

  1. WPF中Datagrid控件添加行号

    /// <summary> /// 导入Excel文件按钮 /// </summary> /// <param name="sender">&l ...

  2. Java 学习笔记 两大集合框架Map和Collection

    两大框架图解 Collection接口 由第一张图,我们可以知道,Collection接口的子接口有三种,分别是List接口,Set接口和Queue接口 List接口 允许有重复的元素,元素按照添加的 ...

  3. ES10特性详解

    摘要: 最新的JS特性. ES10 还只是一个草案.但是除了 Object.fromEntries 之外,Chrome 的大多数功能都已经实现了,为什么不早点开始探索呢?当所有浏览器都开始支持它时,你 ...

  4. PHP多条件分类列表筛选功能开发实例

    PHP多条件分类列表筛选功能开发实例,前后台一起实现 后台对接可以拼接sql语句,PHP通过表单值隐藏值筛选,常用又实用! 表单筛选核心函数 function Filter(a, b) { var $ ...

  5. HTTP长连接--Keep-Alive

    一.HTTP/1.0 HTTP1.0版本的Keep-alive并不像HTTP1.1那样是默认发送的,所以要想连接得到保持,必须手动配置发送connection:keep-alive字段.若想断开kee ...

  6. Django2.0 正则表示匹配的简单例子

    在Django中,使用正则表达式,匹配Url 默认情况下,url固定格式如下: urlpatterns = [ path('admin/', admin.site.urls), ] 如果需要使用正则表 ...

  7. Windows Java包环境变量的设置

    复制Bin文件所在路径 验证

  8. Python第十一天 异常处理 glob模块和shlex模块 打开外部程序和subprocess模块 subprocess类 Pipe管道 operator模块 sorted函数 os模块 hashlib模块 platform模块 csv模块

    Python第十一天    异常处理  glob模块和shlex模块    打开外部程序和subprocess模块  subprocess类  Pipe管道  operator模块   sorted函 ...

  9. location.origin不兼容IE8解决方案

    最近项目中遇到一个问题,在ajax跟后台交互时需要传一个全路径url.项目上线后,在谷歌,火狐,360等浏览器访问一切正常.但唯独IE8下出现问题,提示url:undefined ! 这就尴尬了!!! ...

  10. python实例二

    https://www.cnblogs.com/evablogs/p/6754974.html 题目:企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高于10万元,低于 ...