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 = 0; i <= N - 4; i ++) {int cnt = 0;for(int j = i; j < i + 4; j ++) {if(j == i) {if(s[j] == 'Z') cnt += 1;else cnt += min(s[j] - 'A', ('Z' - s[j] + 1));}if(j == i + 1) cnt += min(abs(s[j] - 'C'), ('Z' - s[j] + 3));if(j == i + 2) cnt += min(abs(s[j] - 'T'), (s[j] - 'A' + 7));if(j == i + 3) cnt += min(abs(s[j] - 'G'), ('Z' - s[j] + 7));}minn = min(minn, cnt);}printf("%d\n", minn);return 0;
}/*
9
AAABBBCCC
*/

View Code

C. Problem for Nazar

代码:

#include <bits/stdc++.h>
using namespace std;const int mod = 1e9 + 7;
long long l, r;long long sum(long long x) {if(x <= 0) return 0;int flag = 1;long long t = 1;long long sum1 = 0, sum2 = 0;for(long long i = 0; i < x; ) {long long nx = min(i + t, x);if(flag) sum1 += (nx - i);else sum2 += (nx - i);t *= 2;i = nx;flag ^= 1;}long long ans = sum2 % mod * ((sum2 + 1) % mod) % mod + sum1 % mod * (sum1 % mod) % mod;return ans % mod;
}int main() {cin >> l >> r;cout << (sum(r) - sum(l - 1) + mod) % mod << endl;return 0;
}

View Code

D. Stas and the Queue at the Buffet

代码:

#include <bits/stdc++.h>
using namespace std;const int maxn = 1e5 + 10;
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 = 1; i <= N; i ++)cin >> node[i].a >> node[i].b;sort(node + 1, node + 1 + N, cmp);long long ans = 0;for(int i = 1; i <= N; i ++)ans += (node[i].a * (i - 1) + node[i].b * (N - i));cout << ans << endl;return 0;
}

View Code

E. Number of Components

代码:

#include <bits/stdc++.h>
using namespace std;const int maxn = 1e5 + 10;
int N;
long long a[maxn];int main() {scanf("%d", &N);for(int i = 1; i <= N; i ++)cin >> a[i];long long ans = 0;for(int i = 1; i <= N; i ++) {if(a[i] > a[i - 1])ans += (a[i] - a[i - 1]) * (N - a[i] + 1);else if(a[i] != a[i - 1])ans += (a[i - 1] - a[i]) * a[i];}cout << ans << endl;return 0;
}

View Code

转载于:https://www.cnblogs.com/zlrrrr/p/10737771.html

CodeForces Round #553 Div2相关推荐

  1. codeforces Round#429 (Div2)

    2017-08-20 10:00:37 writer:pprp 用头文件#include <bits/stdc++.h>很方便 A. Generous Kefa codeforces 84 ...

  2. Codeforces Round#310 div2

    C题:这题说的是套娃,如果做题的时候知道是套娃,那就好理解多了 规则1:套娃A可以放到套娃B里面,当且仅当套娃B没有放在其他套娃里面 规则2:套娃A放在套娃B里面,且套娃B没有放在其他套娃里面,那么可 ...

  3. Codeforces Round #359 div2

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

  4. Codeforces Round 361 div2

    雪崩,全错掉了GG.前两道题相对之前的难度大一点啊,不过A题有个循环应该是从0开始而不是1开始这样的低级错误不应该犯.B题差不多是一个BFS,但是我当时始终绕着最短路径写来写去,一直各种TLE与WA. ...

  5. Codeforces Round #360(div2)

    考完试的晚上,打了场codeforces,主要感觉由于睡眠不够,最后差了点劲啊,C题基本上都过了,但忙中出错最后把数组调小易于debug后再提交又忘记改回来了,看到Runtime Error自己竟没反 ...

  6. codeforces round 416 div2补题

    第一题,水题 A. Vladik and Courtes #include<bits/stdc++.h> using namespace std; int main() {long lon ...

  7. codeforces round 421 div2 补题 CF 820 A-E

    A Mister B and Book Reading  O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef lon ...

  8. codeforces round #576 div2 D Welfare State(线段树)[单点修改+区间修改]

    题意:有一些数字,以及一些操作.操作一是单点修改,输入1 b c,将位置b改成c,操作二是输入2 a,将不大于a的数全部改成a.求更改完毕后的数. tag的运用:tag是对被覆盖区间上加一个标记,那么 ...

  9. codeforces round 418 div2 补题 CF 814 A-E

    A An abandoned sentiment from past 水题 #include<bits/stdc++.h>using namespace std;int a[300],b[ ...

  10. Codeforces Round #267 Div2 C George and Job --DP

    题意:把长度为n的序列分成k个m长的连续小序列,这些连续小序列的和最大是多少. 解法:显然DP. 定义: dp[i][j] 为前 i 个元素分成j个m端,且 i 是第j个的末尾的最大和. 那么有: d ...

最新文章

  1. pandas中使用rolling.corr函数计算两个时间序列数据列之间的滚动相关性(Rolling correlations)、例如,计算两种商品销售额之间的3个月的滚动相关性
  2. WebStorm添加多个项目到当前工程目录
  3. CSharpGL(39)GLSL光照示例:鼠标拖动太阳(光源)观察平行光的漫反射和镜面反射效果...
  4. POJ2251Dungeon Master
  5. java生成excel中文乱码,JSP应用导出Excel报表的简单实现以及中文乱码彻底解决(HTML)...
  6. [leetcode]208. 实现 Trie (前缀树)
  7. SCCM2007系列教程之十操作系统部署(三)
  8. MySQL错误ERROR 1786 (HY000)解决
  9. RS-422接口定义
  10. linux 平铺式桌面,Linux 桌面平铺管理器 - i3wm
  11. 微信公众号开发之iOS分享失败
  12. 幻读Java_关于幻读 - hellopretty - 博客园
  13. 怎样清理计算机c盘东西,怎样清理电脑c盘无用的东西(电脑c盘垃圾清理技巧)...
  14. 大学计算机实验基础第二版,大学计算机基础实验指导(第2版)
  15. IPCam的启动过程和工作流程
  16. 支付平台网站安全解决方案
  17. Angular +Ionic实现关注与取消关注
  18. NLP入门之——Word2Vec词向量Skip-Gram模型代码实现(Pytorch版)
  19. 想瘦身不伤体质,就要学会和脂肪做朋友
  20. pytorch 计算 kl散度 F.kl_div()

热门文章

  1. centos下的mysql安装
  2. PHP精粹:编写高效PHP代码(资深PHP技术专家多……
  3. hrbust 1041(并查集)
  4. Word 相关的快捷键
  5. NLP纠错 | 恶意短信变体字还原、鲁棒性过滤与文本纠错竞赛概述与简单变体实现...
  6. 思考 | 西湖大学博导:都说不唯论文,那我们发表论文是为了什么?
  7. 【工大SCIR笔记】多模态信息抽取简述
  8. 如何高效并快速的掌握NLP与深度学习路径?来公众号寻找经验吧~
  9. 机器学习—XGBoost常见问题解析
  10. 无人驾驶的分级以及产品化后会带来的改善