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. 【记录一次坑经历】axios使用x-www-form-urlencoded 服务器报400(错误的请求。 )(后端.Net MVC5 WebApi OAuth,前端Electron-Vue)

    首先放上源码 electron-vue axios 注册 import Vue from 'vue' import axios from 'axios'   axios.defaults.baseUR ...

  2. C#工具:ASP.NET MVC生成图片验证码

    1.复制下列代码,拷贝到控制器中. #region 生成验证码图片 // [OutputCache(Location = OutputCacheLocation.None, Duration = 0, ...

  3. [转]GitLab-CI与GitLab-Runner

    本文转自:https://www.jianshu.com/p/2b43151fb92e 一.持续集成(Continuous Integration) 要了解GitLab-CI与GitLab Runne ...

  4. c#基础,单线程,跨线程访问和线程带参数

    using System; using System.Collections.Generic; using System.Threading; using System.Windows.Forms; ...

  5. Sqlserver UrlEncode

    Sqlserver  UrlEncode if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[UrlEncode ...

  6. 轻松理解 Java HashMap 和 ConcurrentHashMap

    前言 Map 这样的 Key Value 在软件开发中是非常经典的结构,常用于在内存中存放数据. 本篇主要想讨论 ConcurrentHashMap 这样一个并发容器,在正式开始之前我觉得有必要谈谈 ...

  7. [转载] spring aop 环绕通知around和其他通知的区别

    前言: spring 的环绕通知和前置通知,后置通知有着很大的区别,主要有两个重要的区别: 1) 目标方法的调用由环绕通知决定,即你可以决定是否调用目标方法,而前置和后置通知   是不能决定的,他们只 ...

  8. react 函数子组件(Function ad Child Component)

    今天学习了react中的函数子组件的概念,然后在工作中得到了实际应用,很开心,那么好记性不如烂笔头,开始喽~ 函数子组件(FaCC )与高阶组件做的事情很相似, 都是对原来的组件进行了加强,类似装饰者 ...

  9. CSS---伪类与伪元素的区别

    在CSS中对于伪类和伪元素并没有做出很明显的区别定义,两者的语法是一样的,都是以 : 开头,这样导致我们将一些伪元素误认为伪类,如 :before :after 而在CSS3中给出了明显的定义. ☞ ...

  10. 华为有AI,这场转型战有点大

    华为有AI,这场转型战有点大 https://mp.weixin.qq.com/s/qnUP5cgbNxXcAT82NQARtA 李根 发自 凹非寺 量子位 报道 | 公众号 QbitAI 华为有AI ...