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的更多相关文章

  1. 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,保证有解. ...

  2. Educational Codeforces Round 57 (Rated for Div. 2) D dp

    https://codeforces.com/contest/1096/problem/D 题意 给一个串s,删掉一个字符的代价为a[i],问使得s的子串不含"hard"的最小代价 ...

  3. Educational Codeforces Round 57 (Rated for Div. 2) C 正多边形 + 枚举

    https://codeforces.com/contest/1096/problem/C 题意 问是否存在一正多边形内三点构成的角度数为ang,若存在输出最小边数 题解 三点构成的角是个圆周角,假设 ...

  4. CF Educational Codeforces Round 57划水记

    因为是unrated于是就叫划水记了,而且本场也就用了1h左右. A.B:划水去了,没做 C:大水题,根据初三课本中圆的知识,可以把角度化成弧长,而这是正多边形,所以又可以化成边数,于是假设读入为a, ...

  5. Codeforces Educational Codeforces Round 57 题解

    传送门 Div 2的比赛,前四题还有那么多人过,应该是SB题,就不讲了. 这场比赛一堆计数题,很舒服.(虽然我没打) E. The Top Scorer 其实这题也不难,不知道为什么这么少人过. 考虑 ...

  6. Educational Codeforces Round 57 (Rated for Div. 2)

    我好菜啊. A - Find Divisible 好像没什么可说的. #include<cstdio> #include<cstring> #include<algori ...

  7. Educational Codeforces Round 57题解

    A.Find Divisible 沙比题 显然l和2*l可以直接满足条件. 代码 #include<iostream> #include<cctype> #include< ...

  8. Educational Codeforces Round 57 Solution

    A. Find Divisible 签到. #include <bits/stdc++.h> using namespace std; int t, l, r; int main() { ...

  9. 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 ...

  10. Educational Codeforces Round 57 (Rated for Div. 2) 前三个题补题

    感慨 最终就做出来一个题,第二题差一点公式想错了,又是一波掉分,不过我相信我一定能爬上去的 A Find Divisible(思维) 上来就T了,后来直接想到了题解的O(1)解法,直接输出左边界和左边 ...

随机推荐

  1. bootstrap:按钮下拉菜单

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...

  2. rabbitmq系列(二)几种常见模式的应用场景及实现

    一.简单模式 原理:生产者将消息交给默认的交换机,交换机获取消息后交给绑定这个生产者的队列(投递规则为队列名称和routing key 相同的队列),监听当前队列的消费者获取信息并执行消费逻辑. 场景 ...

  3. 测试工具Fiddler(二)—— 入门使用

    Fiddler设置与安装证书 一.Fiddler常见设置 Options位置:Tools->Options 二.移动端连上Fiddler作为代理 注意:因为Charles也是默认8888端口,小 ...

  4. Redis系列(二):Redis的5种数据结构及其常用命令

    上一篇博客,我们讲解了什么是Redis以及在Windows和Linux环境下安装Redis的方法, 没看过的同学可以点击以下链接查看: Redis系列(一):Redis简介及环境安装. 本篇博客我们来 ...

  5. LeetCode 第三题--无重复字符的最长子串

    1. 题目 2.题目分析与思路 3.思路 1. 题目 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3 ...

  6. Java单体应用 - 开发工具 - 02.Maven

    原文地址:http://www.work100.net/training/monolithic-tools-maven.html 更多教程:光束云 - 免费课程 Maven 序号 文内章节 视频 1 ...

  7. 使用eNSP配置QinQ

    参考链接:https://blog.csdn.net/alone_map/article/details/52217094 本文主要记录使用华为eNSP模拟器来实现配置QinQ,并对QinQ的报文进行 ...

  8. 废旧手机改造之给你的手机安装win10系统

    最近又开始琢磨把我这个即将退出的二手手机再利用一下 发现了一个不错的软件 先上图 是不是感觉逼格很高啊 点击下面链接即可下载使用 https://www.lanzous.com/i4gpsib 欢迎交 ...

  9. Python3之MySQL操作

    1.安装pymysql PyMySQL 是在 Python3.x 版本中用于连接 MySQL 服务器的一个库,在使用之前需要进行安装,可以使用以下命令安装最新版的 PyMySQL: 1).在cmd命令 ...

  10. from .cv2 import * ImportError: DLL load failed: 找不到指定的模块。 >>>

    from .cv2 import * ImportError: DLL load failed: 找不到指定的模块. >>> 昨天看项目的时候遇到这个问题,折腾到深夜,网上的各种方法 ...