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. WPF 中 TextBlock 文本换行与行间距

    换行符: C#代码中:\r\n 或  \r 或 \n XAML中: 或 注:\r 回车 (carriage return 缩写),\n 新行 (new line 缩写). 行间距: LineHeigh ...

  2. html to docx

    public static void main(String[] args) throws Exception{ //创建 POIFSFileSystem 对象 POIFSFileSystem poi ...

  3. jquery接触初级-----juqery 动画函数

    1. window.onload(), 一次只能保存对一个函数的引用:如果多次调用,他会自动用后面的函数覆盖前面的函数 2.$(document).ready(); 会在现有行为上追加新的行为,这些函 ...

  4. python语言中的数据类型之元组

    数据类型 元组       tuple 元组:不可变类型 用途:元组就是一个不可变的列表,当需要存不改动的值时可用元组 定义方式:在()内用逗号分隔开多个任意类型的元素 t=(1,2.2,'aa',( ...

  5. C语言基础入门

    搭建Windows平台C/C++开发环境 第1步: 第2步: 第3步: 第4步: 第5步: 第6步: 第7步: 第8步: 第9步: 第10步: 第11步: 第12步: 第13步: 第14步: 第15步 ...

  6. [ SHELL编程 ] 远程服务器传输文件

    在shell编程中经常需要获取远程服务器文件.手工操作中使用scp命令完成.为避免脚本执行scp输入密码进行交互,需先建立本机服务器当前用户和远程服务器指定用户的信任关系.具体代码见操作实例,重点关注 ...

  7. 免費查看SQL PLAN的工具 - SQL Sentry Plan Explorer

    今天 Terry大 介紹給小弟這個 SQL Sentry Plan Explorer 工具,可以用來看SQL Plan. 什麼? 用SSMS看不就很清楚了嗎? 這個Tool有把SQL Plan幫我們整 ...

  8. vscode 不显示指定后缀名pyc文件

    不显示python生成的pyc文件 不显示java eclipse编辑器生成的.metadata生成的文件夹 py文件执行后会生成.pyc文件,会影响侧边栏的使用,可以通过如下设置隐藏.pyc等中间文 ...

  9. 4.HTTP入门.md

    目录 什么是http协议 http协议:对浏览器客户端 和 服务器端 之间数据传输的格式规范 查看http协议的工具* 使用火狐的firebug插件(右键->firebug->网络) Ht ...

  10. 27.反射2.md

    目录 1.反射 2.类对象获取 3.构造函数获取 4.函数获取 4.注解反射 1.反射 定义:把一个字节码文件加载到内存中,jvm对该字节码文件解析,创造一个Class对象,把字节码文件中的信息全部存 ...