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. VS2017移动开发(C#、VB.NET)——Numeric控件的使用方式

    Visual Studio 2017移动开发 控件介绍和使用方式:Numeric控件 Smobiler开发平台,.NET移动开发 一.          样式一 我们要实现上图中的效果,需要如下的操作 ...

  2. C# 常用小点

    1]创建文件夹 //相对路径 string FilePath = Server.MapPath("./") + "ImageFile/Images/" + Da ...

  3. [Linux] 取两个文件的并集/交集/差集

    uniq -d是只打印重复行 -u是只打印独一无二的行文件A : abcd文件B: cdef取并集:A + B sort A B|uniq 取交集: sort A B|uniq -d 取差集:A - ...

  4. Chrome 下input的默认样式

    一.去除默认边框以及padding border: none;padding:0 二.去除聚焦蓝色边框 outline: none; 三.form表单自动填充变色 1.给input设置内置阴影,至少要 ...

  5. 移动端web自适应适配布局解决方案

    100%还原设计图,要注意: 看布局,分析结构. 感觉难点在于: 1.测量精度(ps测量数据): 2.文字的行高. 前段时间写个移动端适配的页面(刚接触这方面),查了一些资料,用以下方法能实现: 1. ...

  6. Sublime Text 快捷键列表

    Sublime Text 快捷键列表 快捷键按类型分列如下: 补充:1.快速的创建一个html页 :ctrl+n创建一个新的文件-->右下角选择文件类型-->输入英文"!&quo ...

  7. 纯CSS修改checkbox复选框样式-02

    我有用过这个纯修改input属性的 本人修改后的代码和效果图(修的不好), 这个是改动最简单的: css代码 input[type=checkbox]{ visibility: hidden; } i ...

  8. 【图解】FlexGrid Explorer 全功能问世

    前言 在去年的时候,我们推出了FlexGrid Demo,包含了FlexGrid的常用功能,如分组.滚动.冻结.自定义单元格类型.搜索面板.表格过滤器.树形结构.合并单元等,目前我们又在里面添加很多了 ...

  9. Android ScrollView和ListView滑动冲突解决记录

    private int mLastX; private int mLastY; public View.OnTouchListener onTouchListener = new View.OnTou ...

  10. android 开发之 ListView 与Adapter 应用实践

    在开发android中,ListView 的应用显得非常频繁,只要需要显示列表展示的应用,可以说是必不可少,下面是记录开发中应用到ListView与Adapter 使用的实例: ListView 所在 ...