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 ...
随机推荐
- .NET Core微服务之基于MassTransit实现数据最终一致性(Part 2)
Tip: 此篇已加入.NET Core微服务基础系列文章索引 一.案例结构与说明 在上一篇中,我们了解了MassTransit这个开源组件的基本用法,这一篇我们结合一个小案例来了解在ASP.NET C ...
- 【Android Studio安装部署系列】二十六、Android studio录制屏幕并生成gif文件
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 Android Studio自带录制屏幕功能,那么就可以很方便地将手机上的屏幕操作录制成视频.然后借助一些软件或者网站转换成gif文 ...
- 让你的ASP.NET Core应用程序更安全
让你的ASP.NET Core应用程序更安全 对于ASP.NET Core应用程序,除了提供认证和授权机制来保证服务的安全性,还需要考虑下面的一些安全因素: CSRF 强制HTTPS 安全的HTTP ...
- Springboot 系列(十二)使用 Mybatis 集成 pagehelper 分页插件和 mapper 插件
前言 在 Springboot 系列文章第十一篇里(使用 Mybatis(自动生成插件) 访问数据库),实验了 Springboot 结合 Mybatis 以及 Mybatis-generator 生 ...
- [转]Date and String Function in BluePrism
本文转自:https://www.codeproject.com/Articles/1247389/Date-and-String-Function-in-BluePrism This article ...
- Convert.ToInt32()和int.Parse()区别
Convert.ToInt32()和int.Parse()都可以数据转换个int类型,区别在于: 1. Convert.ToInt32()将object类类型转换成int类型,例如:Convert.T ...
- 折腾Java设计模式之单例模式
博文原址:折腾Java设计模式之单例模式 单例模式 Ensure a class has only one instance, and provide a global point of access ...
- Django学习之十一:真正理解Django的路由分发和反解url原理
目录 URL Dispatcher 简介 模式概念 对比URLPattern 与 URLResolver (多态的体现) 构建子路由几种方式 反解url算法逻辑 URL Dispatcher 简介 d ...
- css3 笔记 背景
.div1 { height: 80px; background: linear-gradient( 135deg, transparent 0, transparent 49.5%, green 4 ...
- 使用 Scrapy 爬取股票代码
个人博客: https://mypython.me 源码地址: https://github.com/geeeeeeeek/scrapy_stock 抓取工具:scrapy scrapy 介绍 Scr ...