Education CodeForces Round 63 Div.2
A. Reverse a Substring
代码:
#include <bits/stdc++.h>
using namespace std; int N;
string s; int main() {
scanf("%d", &N);
cin >> s; int temp = -;
for(int i = ; s[i]; i ++) {
if(s[i] < s[i - ]) {
temp = i;
break;
}
} if(temp == -) printf("NO\n");
else {
printf("YES\n");
temp += ;
printf("%d %d\n", temp - , temp);
} return ;
}
B. Game with Telephone Numbers
代码:
#include <bits/stdc++.h>
using namespace std; int N;
int eight = ;
string s; int main() {
scanf("%d", &N);
cin >> s;
bool flag = true;
for(int i = ; i <= N - ; i ++) {
if(s[i] == '')
eight ++;
}
if(eight <= ((N - ) / )) flag = false; if(flag) printf("YES\n");
else printf("NO\n"); return ;
}
C. Alarm Clocks Everywhere
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 3e5 + ;
int N, M;
long long a[maxn], p[maxn], b[maxn]; long long gcd(long long a, long long b) {
return b == ? a : gcd(b, a % b);
} int main() {
scanf("%d%d", &N, &M);
long long t;
for(int i = ; i <= N; i ++) {
cin >> a[i];
//scanf("%lld", &a[i]);
if(i == ) b[i] = ;
else b[i] = a[i] - a[i - ];
} for(int i = ; i <= N; i ++) {
if(i == ) t = b[i];
else t = gcd(t, b[i]);
} bool flag = false;
int temp;
for(int i = ; i <= M; i ++) {
cin >> p[i];
//scanf("%lld", &p[i]);
if(t % p[i] == ) {
temp = i;
flag = true;
}
} int ansp = temp;
if(!flag) printf("NO\n");
else {
printf("YES\n");
cout << a[] << " " << ansp << endl;
} return ;
}
D. Beautiful Array
代码:(D 神仙 dp 自己写了贪心 但是不对有一些情况不可以 枯了 )
#include <bits/stdc++.h>
using namespace std; const int maxn = 3e5 + ;
long long a[maxn], dp[maxn][];
int N, K; int main() {
memset(dp, -1e18, sizeof(dp));
scanf("%d%d", &N, &K);
long long ans = ;
for(int i = ; i <= N; i ++) {
cin >> a[i];
dp[i][] = max(dp[i - ][], 0LL) + a[i];
dp[i][] = max(max(dp[i - ][], dp[i - ][]), 0LL) + 1LL * K * a[i];
dp[i][] = max(max(max(dp[i - ][], dp[i - ][]), dp[i - ][]), 0LL) + a[i];
ans = max(ans, max(dp[i][], max(dp[i][], dp[i][])));
}
cout << ans << endl;
return ;
}
Education CodeForces Round 63 Div.2的更多相关文章
- Educational Codeforces Round 63 Div. 2
A:找到两个相邻字符使后者小于前者即可. #include<bits/stdc++.h> using namespace std; #define ll long long #define ...
- Codeforces Beta Round #63 (Div. 2)
Codeforces Beta Round #63 (Div. 2) http://codeforces.com/contest/69 A #include<bits/stdc++.h> ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- CF922 CodeForces Round #461(Div.2)
CF922 CodeForces Round #461(Div.2) 这场比赛很晚呀 果断滚去睡了 现在来做一下 A CF922 A 翻译: 一开始有一个初始版本的玩具 每次有两种操作: 放一个初始版 ...
- Codeforces Round #545 (Div. 1) 简要题解
这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...
- Codeforces Round #455 (Div. 2)
Codeforces Round #455 (Div. 2) A. Generate Login 题目描述:给出两个字符串,分别取字符串的某个前缀,使得两个前缀连起来的字符串的字典序在所有方案中最小, ...
- Codeforces Round #556 (Div. 1)
Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶 ...
- [Educational Codeforces Round 63 ] D. Beautiful Array (思维+DP)
Educational Codeforces Round 63 (Rated for Div. 2) D. Beautiful Array time limit per test 2 seconds ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
随机推荐
- CAS、原子操作类的应用与浅析及Java8对其的优化
前几天刷朋友圈的时候,看到一段话:如果现在我是傻逼,那么我现在不管怎么努力,也还是傻逼,因为我现在的傻逼是由以前决定的,现在努力,是为了让以后的自己不再傻逼.话糙理不糙,如果妄想现在努力一下,马上就不 ...
- 网络协议 18 - CDN:家门口的小卖铺
[前五篇]系列文章传送门: 网络协议 13 - HTTPS 协议:加密路上无尽头 网络协议 14 - 流媒体协议:要说爱你不容易 网络协议 15 - P2P 协议:小种子大学问 网络协议 16 - D ...
- ionic4 混合移动开发 (前世今生)
ionic 从2016年初识,经历了 ionic2 ionic3.至今 ionic4,终于在2018年7月份发布了测试版. ionic Framework 可以说得上是最接近原生app的ui组件,漂亮 ...
- java~gradle构建公用包并上传到仓库~使用私有仓库的包
在新的项目里使用仓库的包 上一讲中我们说了java~gradle构建公用包并上传到仓库,如何发布公用的非自启动类的包到私有仓库,而这一讲我们将学习如何使用这些包,就像我们使用spring框架里的功能包 ...
- windows系统下用python更新svn和Git
转载请标明出处:http://www.cnblogs.com/zblade/ 最近在思考怎么实现python的一键打包,利用python的跨平台特性,可以实现在windows和mac下均可执行的特点. ...
- RDIFramework.NET V3.3 WinForm版新增日程管理功能模块
功能描述 日程管理基于月.周.日的日历视图,把安排到每一天的具体时间点,让每一天的时间都充分利用:甚至您也可以把个人非工作事项也安排进来,完全是属于自己的全时间管理.就是将每天的工作和事务安排在日期中 ...
- 物联网RFID技术之应用ETC系统
背景 信息物理系统CPS通过集成先进的感知.计算.通 信.控制等信息技术和自动控制技术,构建了物理空间与信息空间中人. 机.物.环境.信息等要素相互映射.适时交互.高效协同的复杂系统, 实现系统内资源 ...
- spring boot 2.0 ribbon 负载均衡配置
1.pom.xml <dependency> <groupId>org.springframework.cloud</groupId> <artifactId ...
- python3 爬取boss直聘职业分类数据(未完成)
import reimport urllib.request # 爬取boss直聘职业分类数据def subRule(fileName): result = re.findall(r'<p cl ...
- 折腾Java设计模式之状态模式
原文地址 折腾Java设计模式之状态模式 状态模式 在状态模式(State Pattern)中,类的行为是基于它的状态改变的.这种类型的设计模式属于行为型模式.在状态模式中,我们创建表示各种状态的对象 ...