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)解法,直接输出左边界和左边 ...
随机推荐
- window 下配置wamp 环境
PHP下载 下载php压缩包,几点注意:这里我安装的事apache 所以在 php官方下载页时不是随便下载的,不然可能配置不了apache! 注意我以下图片标注
- Go合集,gRPC源码分析,算法合集
年初时,朋友圈见到的最多的就是新的一年新的FlAG,年末时朋友圈最多的也是xxxx就要过去了,你的FLAG实现了吗? 这个公众号2016就已经创建了,但截至今年之前从来没发表过文章,现在想想以前很忙, ...
- 观察者模式的应用:Winform窗体之间传值
观察者模式的应用:Winform窗体传值 观察者模式的概念: 定义了对象之间的一对多依赖,这样一来,当一个对象改变状态时,它的所有依赖者都会收到通知并更新. 今天我们就学着用一下这个观察者模式,先想象 ...
- 抽象工厂模式(C++)
#include <iostream> using namespace std; class Fruit { public: ; }; class AbstractFactory { pu ...
- Unity事件系统EventSystem简析
相关组件和类 EventSystem 1.负责InputModule的切换(因为现在游戏大部分都只有一个StanaloneInputModule,所以切换这部分可以先不考虑). 2.负责InputMo ...
- 使用log4j把日志写到mysql数据库
log4j可以支持将log输出到文件,数据库,甚至远程服务器,本教程以mysql数据库为例来讲解: 作者:Jesai 没有伞的孩子,只能光脚奔跑! 1.数据库设计 数据库表 表4-1日志表(log) ...
- Docker学习(九)Volumn容器间共享数据
Docker学习(九)Volumn容器间共享数据 volume是什么 volume在英文中是容量的意思, 在docker中是数据卷的意思,是用来保存数据的容器 为什么要进行数据共享 在集群中有多台to ...
- PageHelper踩坑
刚开始死活分不了页,只显示默认的前 10条.搞了一下午,打了无数个断点都试不出毛病在哪. 下班又死磕到快8点,就在我已经绝望的时候,最后终于试出来了,把page.getTotal()给传到前端就好了. ...
- Ubuntu下makefile的简单使用
在Windows下,只需要简单的点击以下make,rebuild即可.而在Linux下,这样的IDE环境并没有提供,难道必须每一步都执行一遍吗?比较ok的做法自然是能够利用批处理脚本来进行操作了,这样 ...
- python接口自动化测试 - configparser配置文件解析器详细使用
configparser简介 ConfigParser模块已在Python 3中重命名为configparser 该模块定义了ConfigParser类. ConfigParser类实现一种基本的配置 ...