Educational Codeforces Round 57
2018.12.28 22:30
看着CF升高的曲线,摸了摸自己的头发,我以为我变强了,直到这一场Edu搞醒了我。。
从即将进入2018年末开始,开启自闭场集合,以纪念(dian)那些丢掉的头发
留坑睡觉。。明天看题解再补
A.Find Divisible
题意:输出[l,r]中满足x|y的x,y,保证有解
思路:直接输出x, 2x即可
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = 1e9+;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); int main() {
int t;
scanf("%d", &t);
while(t--){
ll x, y;
scanf("%lld %lld", &x, &y);
printf("%lld %lld\n", x,*x);
}
return ;
}
B.Substring Removal
题意:删除一个子串,使得剩下的串只有一种字符,问你方案数
思路:分a[1]是否==a[n]两种情况讨论,
等于的时候根据要删除的子串区间端点范围决定方案数
不等于的时候相当于一个端点固定
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = ;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);
char a[maxn];
int main() {
int n;
scanf("%d", &n);
getchar();
scanf("%s", a+);
ll ans = ;
if(a[]==a[n]){
char c = a[];
int l , r;
for(int i = ; i <= n; i++){
if(a[i]!=c){l=i;break;}
}
for(int i = n; i >= ; i--){
if(a[i]!=c){r=i;break;}
}
l = l;
r = n-r+;
ans = 1ll*l*r;
ans%=mod;
}
else{
int l,r;
char c = a[];
for(int i = ; i <= n; i++){
if(a[i]!=c){l=i;break;}
}
c = a[n];
for(int i = n; i >= ; i--){
if(a[i]!=c){r=i;break;}
}
ans = n-r;
ans += l;
ans%=mod;
}
printf("%lld", ans);
return ;
}
C.Polygon for the Angle
题意:问你一个角度最少存在于正几边形中
思路:看代码。。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = ;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); int main() {
int t;
scanf("%d", &t);
while(t--){
int ag;
scanf("%d", &ag);
int g = __gcd(ag,);
int n = /g;
int m = ag/g;
while(m>n-){n*=;m*=;}
printf("%d\n", n);
}
return ;
}
D.Easy Problem
题意:给你一个字符串,每个字符都有权重,问你删掉多少权重和的字符,使得剩下的字符没有"hard"子序列,并且这个权重和最小
思路:dp[i][j]为前i个字符最多拥有j状态的子序列需要删除的最小权重
其中 j=0代表空,j=1代表"h",j=2代表"ha",j=3代表"har"
转移方程在代码里
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = ;
const int maxn = 2e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);
char s[maxn];
ll dp[maxn][];
//dp[i][j]表示前i个字符最多有prej作为子序列要删多少
int a[maxn];
int n;
int main() {
scanf("%d", &n);
getchar();
scanf("%s", s+);
for(int i = ; i <= n; i++){
scanf("%d", &a[i]);
}
mem(dp,);
//dp[0][0] = 0;
for(int i = ; i <= n; i++){
for(int j = ; j < ; j++){
dp[i][j] = dp[i-][j];
}
if(s[i]=='h')dp[i][]+=a[i];
if(s[i]=='a')dp[i][]=min(dp[i-][],dp[i][]+a[i]);
if(s[i]=='r')dp[i][]=min(dp[i-][],dp[i][]+a[i]);
if(s[i]=='d')dp[i][]=min(dp[i-][],dp[i][]+a[i]);
}
ll ans = 0x7f7f7f7f7f7f7f7f;
for(int i = ; i <= ;i++){
ans = min(ans, dp[n][i]);
}printf("%lld", ans);
return ;
}
Educational Codeforces Round 57的更多相关文章
- Educational Codeforces Round 57 (Rated for Div. 2) ABCDEF题解
题目总链接:https://codeforces.com/contest/1096 A. Find Divisible 题意: 给出l,r,在[l,r]里面找两个数x,y,使得y%x==0,保证有解. ...
- Educational Codeforces Round 57 (Rated for Div. 2) D dp
https://codeforces.com/contest/1096/problem/D 题意 给一个串s,删掉一个字符的代价为a[i],问使得s的子串不含"hard"的最小代价 ...
- Educational Codeforces Round 57 (Rated for Div. 2) C 正多边形 + 枚举
https://codeforces.com/contest/1096/problem/C 题意 问是否存在一正多边形内三点构成的角度数为ang,若存在输出最小边数 题解 三点构成的角是个圆周角,假设 ...
- CF Educational Codeforces Round 57划水记
因为是unrated于是就叫划水记了,而且本场也就用了1h左右. A.B:划水去了,没做 C:大水题,根据初三课本中圆的知识,可以把角度化成弧长,而这是正多边形,所以又可以化成边数,于是假设读入为a, ...
- Codeforces Educational Codeforces Round 57 题解
传送门 Div 2的比赛,前四题还有那么多人过,应该是SB题,就不讲了. 这场比赛一堆计数题,很舒服.(虽然我没打) E. The Top Scorer 其实这题也不难,不知道为什么这么少人过. 考虑 ...
- Educational Codeforces Round 57 (Rated for Div. 2)
我好菜啊. A - Find Divisible 好像没什么可说的. #include<cstdio> #include<cstring> #include<algori ...
- Educational Codeforces Round 57题解
A.Find Divisible 沙比题 显然l和2*l可以直接满足条件. 代码 #include<iostream> #include<cctype> #include< ...
- Educational Codeforces Round 57 Solution
A. Find Divisible 签到. #include <bits/stdc++.h> using namespace std; int t, l, r; int main() { ...
- Educational Codeforces Round 57 (Rated for Div. 2)D(动态规划)
#include<bits/stdc++.h>using namespace std;char s[100007];long long a[100007];long long dp[100 ...
- Educational Codeforces Round 57 (Rated for Div. 2) 前三个题补题
感慨 最终就做出来一个题,第二题差一点公式想错了,又是一波掉分,不过我相信我一定能爬上去的 A Find Divisible(思维) 上来就T了,后来直接想到了题解的O(1)解法,直接输出左边界和左边 ...
随机推荐
- Java小白集合源码的学习系列:ArrayList
ArrayList源码学习 本文基于JDK1.8版本,对集合中的巨头ArrayList做一定的源码学习,将会参考大量资料,在文章后面都将会给出参考文章链接,本文用以巩固学习知识. ArrayList的 ...
- 为WPF, UWP 及 Xamarin实现一个简单的消息组件
原文地址:Implementing a simple messenger component for WPF, UWP and Xamarin 欢迎大家关注我的公众号:程序员在新西兰了解新西兰IT行业 ...
- 怎样使用七牛云CDN加速并绑定阿里云域名
昨天晚上在某个群里看到群友问,七牛云能不能绑定自己的域名作为静态资源文件的前缀,忽然想起来我已经有快两年时间没有登录过我的七牛云账号了,不禁老脸一红,这是有多久没有自己前后端都弄了,幸好还没有老年痴呆 ...
- 容器环境的JVM内存设置最佳实践
Docker和K8S的兴起,很多服务已经运行在容器环境,对于java程序,JVM设置是一个重要的环节.这里总结下我们项目里的最佳实践. Java Heap基础知识 默认情况下,jvm自动分配的heap ...
- Python知识体系框架 思维导图
技术文档已经独立整理! 请移步个人技术文档:https://anxiangchegu.github.io/technical-doc 如需更多Java.Python.大数据体系知识,请稳移步个人技术文 ...
- mysql 注入问题
1.实质 MySql语句是用户自行拼接的字符串 2.例子 import pymysql # 获取用户输入信息 username = input("请输入用户名:") pwd = i ...
- @ControllerAdvice自定义异常统一处理
正常来说一个系统肯定有很多业务异常.而这些业务异常的信息如何返回给前台呈现给用户.比如用户的某些操作不被允许,需要给用户提示. Spring 提供了@ControllerAdvice这个注解,这个注解 ...
- 解决android sdk无法更新 更新慢的问题
使用不同平台开发android应用的时候都要先搭建开发环境. 这里介绍一下搭建开发环境过程中更新和下载android sdk的一种方法: 第一步:配置android sdk manager的代理服务, ...
- windows下RocketMQ安装部署
一.预备环境 1.系统 Windows 2. 环境 JDK1.8.Maven.Git 二. RocketMQ部署 1.下载 1.1地址:http://rocketmq.apache.org/relea ...
- 制作一个类“全能扫描王”的简易扫描软件(opencv)
相信很多人手机里都装了个“扫描全能王”APP,平时可以用它来可以扫描一些证件.文本,确实很好用,第一次用的时候确实感觉功能很强大啊算法很牛逼啊.但是仔细一想,其实这些实现起来也是很简单的,我想了下,实 ...