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

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  8. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  9. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

随机推荐

  1. 线程池构造类 ThreadPoolExecutor 的 5 个参数

    1.corePoolSize :核心线程数 2.maxPoolSize: 最大线程数 3.keepAliveTime :闲置线程存活时间 4.unit:参数keepAliveTime的时间单位,有7种 ...

  2. WPF 透明窗体

    窗体属性中设置:Background="Transparent" AllowsTransparency="True" WindowStyle="Non ...

  3. JQuery中bind和unbind函数与onclick绑定事件区分

    JQuery中bind和unbind函数转载:   https://blog.csdn.net/liucheng417/article/details/51131982 页面代码: <body& ...

  4. centos 卸载mysql

    1 删除Mysql yum remove  mysql mysql-server mysql-libs mysql-server; find / -name mysql 将找到的相关东西delete掉 ...

  5. libcurl+OpenSSL 库分享

    首先,我要感谢这两个博客给我的帮助: https://www.cnblogs.com/findumars/p/7496122.html https://blog.csdn.net/yannanxiu/ ...

  6. c++复习:STL之理论基础

    1 STL(标准模板库)理论基础 1.1基本概念 STL(Standard Template Library,标准模板库)是惠普实验室开发的一系列软件的统称.现然主要出现在C++中,但在被引入C++之 ...

  7. void类型详解

    void含义 void的字面意思是"无类型",void*则为"无类型指针",void*可以指向任何类型的数据. void几乎只有"注释"和限 ...

  8. openvpn 批量生成用户脚本

    #/bin/bash for user in "$@" do echo "新增用户:$user" if [ -d "/etc/openvpn/clie ...

  9. 编译安装php5 解决编译安装的php加载不了gd

    1. 编译安装php需要的模块: yum install libxml2-devel libxml2  curl curl-devel  libpng-devel  libpng  openssl o ...

  10. JS 实现分页打印

    在调用window.print()时,可以实现打印效果,但内容太多时要进行分页打印. 在样式中有规定几个打印的样式 page-break-before和page-break-after CSS属性并不 ...