Codeforces Beta Round #54 (Div. 2)
Codeforces Beta Round #54 (Div. 2)
http://codeforces.com/contest/58
A
找子序列
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string str;
string s="hello";
cin>>str;
int i=,j=;
while(i<s.length()&&j<str.length()){
if(s[i]==str[j]){
i++,j++;
}
else{
j++;
}
}
if(i==s.length()){
cout<<"YES"<<endl;
}
else cout<<"NO"<<endl;
}
B
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=n;i>=;i--){
if(n%i==){
cout<<i<<" ";
n=i;
}
}
}
C
逆向思维,求出最多不需要修改的数量,然后减去它即可
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n;
int a[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
int m;
int ans=;
for(int i=;i<=n;i++){
cin>>m;
int num=min(i,n-i+);
m-=num;
if(m>=){
a[m]++;
ans=max(ans,a[m]);
}
}
cout<<n-ans<<endl; }
D
在每个字符串后面加上字符d,然后sort+贪心即可
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n;
string str[];
int book[];
string ans[];
string d; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
int sum=;
for(int i=;i<=n;i++){
cin>>str[i];
sum+=str[i].length();
}
cin>>d;
for(int i=;i<=n;i++){
str[i]+=d;
}
sum+=n/;
int len=sum/(n/);
int co=;
sort(str+,str+n+);
for(int i=;i<=n;i++){
if(!book[i]){
ans[co]=str[i];
book[i]=;
for(int j=;j<=n;j++){
if(!book[j]&&str[i].length()-+str[j].length()==len){
ans[co]+=str[j].substr(,str[j].length()-);
book[j]=;
co++;
break;
}
}
}
}
for(int i=;i<co;i++){
cout<<ans[i]<<endl;
}
}
E
搜索
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; ll ans1,ans2;
ll p[];
ll ans=;
void dfs(ll a,ll b,ll c,ll ra,ll rb, ll jw, ll inc,ll d){
if(inc>=ans) return;
if(!a&&!b&&!c&&!jw){
ans=inc;ans1=ra;ans2=rb;return;
}
if(!c){
ll s=a+b+jw;
int k=;
while(s){
s/=;
k++;
}
dfs(,,,a*p[d]+ra,b*p[d]+rb,,inc+k,d);
return;
}
if((a+b+jw)%==c%){
dfs(a/,b/,c/,a%*p[d]+ra,b%*p[d]+rb,(a%+b%+jw)/,inc,d+);
}
else{
dfs(a*+(c+-b%-jw)%,b,c,ra,rb,jw,inc+,d);
dfs(a,b*+(c+-a%-jw)%,c,ra,rb,jw,inc+,d);
dfs(a,b,c*+(a+b+jw)%,ra,rb,jw,inc+,d);
}
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
ll a,b,c;
char ch;
cin>>a>>ch>>b>>ch>>c;
p[]=;
for(int i=;i<=;i++) p[i]=p[i-]*;
dfs(a,b,c,,,,,);
cout<<ans1<<"+"<<ans2<<"="<<ans1+ans2<<endl;
}
Codeforces Beta Round #54 (Div. 2)的更多相关文章
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
- Codeforces Beta Round #72 (Div. 2 Only)
Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...
随机推荐
- 使用spring validation完成数据后端校验
前言 数据的校验是交互式网站一个不可或缺的功能,前端的js校验可以涵盖大部分的校验职责,如用户名唯一性,生日格式,邮箱格式校验等等常用的校验.但是为了避免用户绕过浏览器,使用http工具直接向后端请求 ...
- 机器学习进阶-阈值与平滑-图像阈值 1. cv2.threshold(进行阈值计算) 2. 参数type cv2.THRESH_BINARY(表示进行二值化阈值计算)
1. ret, dst = cv2.thresh(src, thresh, maxval, type) 参数说明, src表示输入的图片, thresh表示阈值, maxval表示最大值, type表 ...
- 数据库操作API 或万能的双下划线
数据库操作API: 类型 描述 exact 精确匹配: polls.get_object(id__exact=14). iexact 忽略大小写的精确匹配: polls.objects.filter( ...
- Spark/Storm/Flink
https://www.cnblogs.com/yaohaitao/p/5703288.html Spark Streaming与Storm的应用场景 对于Storm来说:1.建议在那种需要纯实时, ...
- English Phrases with THE – Linking the TH Sound
English Phrases with THE – Linking the TH Sound Share Tweet Share Tagged With: The Word THE Study En ...
- 【367】通过 python 实现 SVM 硬边界 算法
参考: 支持向量机整理 SVM 硬边界的结果如下: $$min \quad \frac{1}{2} \sum_{i=1}^m\sum_{j=1}^m \alpha_i\alpha_jy_iy_j \v ...
- c/c++基础 const
int main(int argc, char* argv[]) { '; '; a1='; //a2='2'; //a2是字符常量 "; "; a3="; //a4=& ...
- MyBatis动态SQL中trim标签的使用
My Batis 官方文档 对 动态SQL中使用trim标签的场景及效果介绍比较少. 事实上trim标签有点类似于replace效果. trim 属性 prefix:前缀覆盖并增加其内容 suffix ...
- Cache雪崩效应
大概半年前,Guang.com曾发生一次由于首页部分cache失效,导致网站故障. 故障分析: 当时逛正在做推广,流量突然暴增,QPS达到5000+,当首页部分cache失效时,需要查询DB, 但由于 ...
- easyUi 表头排序按钮 bug
参考文章:https://www.shiqidu.com/p/81