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 ...
随机推荐
- TP的di
依赖注入的意思是通过反射分析类所依赖的其他类,从容器中获取相应的对象并自动注入到类里面 首先依赖注入和控制反转说的是同一个东西,是一种设计模式,这种设计模式用来减少程序间的耦合,鄙人学习了一下,看TP ...
- react-native android 集成 react-native-baidu-map
记录下 遇到的问题,方便以后查看,参考 文章 https://www.jianshu.com/p/7ca4d7acb6d2 1. npm install react-native-baidu-map ...
- VS的release工程设置为可调试
参考:http://wineworm.blog.163.com/blog/static/29822754201111602252932/ VS2008 Release 工程调试修改方式: 1.项目—— ...
- 彻底关闭Windows Defender丨Win10
关闭Windows Defender Win10正式版怎么关闭windows defender 首先关闭windows defender,因重启电脑后win10 会自动重启defender,所以需要禁 ...
- day10-连接mysql虚拟机报错
连接mysql时报:message from server: "Host '192.168.76.1' is not allowed to connect to this MySQL ser ...
- WDA-1-环境配置
1.Internet Communication Manager 确认ICM中提供的HTTP/HTTPS运行正常. Tcode: SMICM -> Display service. ICM在SA ...
- JAVA_Class.forName
Class.forName(xxx.xx.xx) 返回的是一个类 ,作用是要求JVM查找并加载指定的类,也就是说JVM会执行该类的静态代码段 --------- 首先,在java里面任何class都要 ...
- vue项目分辨率
vue项目分辨率写在这里:
- [C语言]使用函数
------------------------------------------------------------------------------------------ //函数原型声明: ...
- PHP搜索中的sql注入
----------------------------------------------------------------------------------------- 防止查询的sql攻击 ...