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. JAVA版开源微信管家—JeeWx捷微3.2版本发布,支持微信公众号,微信企业号,支付窗、小程序

    JeeWx捷微3.2微信企业号升级版本发布^_^ JeeWx捷微V3.2——多触点管理平台(支持微信公众号,微信企业号,支付窗.小程序)   JeeWx捷微V3.2.0版本引入了更多新特性,支持微信公 ...

  2. jsfl 常用自定义方法

    //创建文件夹 function creatFile(fileURl) { if (FLfile.createFolder(fileURl)) { //alert("创建成功 "+ ...

  3. C#利用CDO.Message发送邮件

    如何引用CDO.Message? cod.message的引用位置: C:\Windows\System32\cdosys.dll CDO.Message objMail = new CDO.Mess ...

  4. Hive安装与配置--- 基于MySQL元数据

    hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供简单的sql查询功能,可以将sql语句转换为MapReduce任务进行运行. 其优点是学习成本低,可以通过 ...

  5. Linux性能测试分析命令_top

    top命令动态展示系统整体资源和各个进程资源占用状况,是Linux下常用的性能分析工具. top命令语法 使用格式:top [-] [d] [b] [H] [p] [q] [c] [C] [S] [s ...

  6. React/anu实现Touchable

    在RN中有一个叫Touchable 的组件,这里我们重演如何实现它. Touchable存在的意义是屏蔽click的问题.移动端与手机的click 在一些浏览器是有差异,比如说著名的300ms延迟. ...

  7. 【原】Win7 host 与 virtualbox ubuntu guest 相同ping通

    环境:Win7 host 与 virtualbox ubuntu guest 在 “设置”-->"网络" 中选择网卡1,修改连接方式为 “桥接网卡” 后, 主机和虚拟机可以相 ...

  8. Structs复习 Action传递参数

    Structs传递参数通常有三种方式 下面我来一个个介绍 1.属性 Jar包 web.xml <?xml version="1.0" encoding="UTF-8 ...

  9. C# 如何获取屏幕的截图,以及如何在图像上添加文字

    关键代码为 Screen sc = Screen.PrimaryScreen; Rectangle rct = sc.Bounds; Image img = new Bitmap(rct.Width, ...

  10. Uni2D 入门 -- Animation Clip 和 Animation API

    转载 csdn kakashi8841 http://blog.csdn.net/kakashi8841/article/details/17599505 Animation Clip 一个anima ...