Codeforces Beta Round #49 (Div. 2)
Codeforces Beta Round #49 (Div. 2)
http://codeforces.com/contest/53
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; string s[]; int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string str;
cin>>str;
int n;
cin>>n;
for(int i=;i<=n;i++){
cin>>s[i];
}
string ans=str;
int flag=;
for(int i=;i<=n;i++){
if(s[i].find(str)==){
if(!flag) ans=s[i],flag=;
else ans=min(ans,s[i]);
}
}
cout<<ans<<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++)
#define eps 1e-8
typedef long long ll;
typedef unsigned long long ull; ///w/h>=0.8&&w/h<=1.25 ll num[];
ll h,w; int sgn(double x){
if(x<) return -;
if(x<eps) return ;
return ;
}
vector<double>tmp; bool Check1(ll mid,ll h){
double zhi=(mid*1.0)/(h*1.0);
if(sgn(zhi-0.8)>=&&sgn(1.25-zhi)>=) return true;
return false;
} bool Check2(ll h,ll mid){
double zhi=(mid*1.0)/(h*1.0);
if(sgn(zhi-0.8)>=&&sgn(1.25-zhi)>=) return true;
return false;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>h>>w;
num[]=;
ll l,r,mid;
ll ans=;
ll ansh,answ;
for(int i=;i<=;i++) num[i]=num[i-]*;
for(int i=;i<=;i++){
if(h>=num[i]){
l=ll(ceil(num[i]*0.8)); if(ll(num[i]*1.25)<=w) r=num[i]*1.25;
else r=w;
// if(h==5&&w==5) cout<<l<<" "<<r<<endl;
if(l>r) continue;
while(l<=r){
mid=l+r>>;
if(Check1(mid,num[i])) l=mid+;
else r=mid-;
}
if(ans<=r*num[i]){
ans=r*num[i];
ansh=num[i],answ=r;
}
}
}
for(int i=;i<=;i++){
if(w>=num[i]){
/* l=ll(ceil(num[i]/0.8));
if(ll(num[i]/1.25)<=w) r=num[i]*1.25;
else r=h;*/
l=ceil(num[i]*1.0/1.25);
r=min(h,ll(num[i]*1.0/0.8));
// cout<<l<<" "<<r<<endl;
// if(h==5&&w==5) cout<<l<<" "<<r<<endl;
if(l>r) continue;
while(l<=r){ mid=l+r>>;//cout<<mid<<endl;
if(Check2(num[i],mid)) l=mid+;
else r=mid-;
}
if(ans<=r*num[i]){
ans=r*num[i];
answ=num[i],ansh=r;
}
}
}
if(ansh<answ){
if(answ<=h) swap(ansh,answ);
}
cout<<ansh<<" "<<answ<<endl;
}
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 main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
int L=,R=n;
for(int i=;i<=n;i++){
if(i%){
cout<<L++<<" ";
}
else{
cout<<R--<<" ";
}
} }
D
模拟
#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 a[],b[];
vector<pair<int,int> >ve; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=;i<=n;i++) cin>>a[i];
for(int i=;i<=n;i++) cin>>b[i];
int j;
for(int i=;i<=n;i++){
if(a[i]!=b[i]){
for(j=i+;j<=n;j++){
if(a[i]==b[j]){
break;
}
}
for(;j>i;j--){
ve.pb(make_pair(j-,j));
swap(b[j],b[j-]);
}
}
}
cout<<ve.size()<<endl;
for(int i=;i<ve.size();i++){
cout<<ve[i].first<<" "<<ve[i].second<<endl;
}
}
E
状压DP
这题思路很奇妙,有些细节还没理解清楚
参考博客:https://www.luogu.org/problemnew/solution/CF53E
#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,m,k;
int g[][];
int dp[][];
int ans; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m>>k;
int u,v,x;
rep(i,,m){
cin>>u>>v;
u--,v--;
x=(<<u)|(<<v);
g[u][v]=g[v][u]=;
dp[x][x]=;
}
rep(i,,<<n){
rep(j,,<<n){
if(i&j==j&&dp[i][j]){
rep(k,,n){
rep(w,,n){
if (g[k][w]&&(i&(<<k))&&(~i&(<<w))&&(!(((j&(~(<<k)))|(<<w))>>(w+)))){
dp[i|(<<w)][(j&(~(<<k)))|((<<w))]+=dp[i][j];
}
}
}
}
}
}
int nn=(<<n)-;
rep(i,,<<n){
if(__builtin_popcount(i)==k){
ans+=dp[nn][i];
}
}
cout<<ans<<endl;
}
Codeforces Beta Round #49 (Div. 2)的更多相关文章
- Codeforces Beta Round #46 (Div. 2)
Codeforces Beta Round #46 (Div. 2) http://codeforces.com/contest/49 A #include<bits/stdc++.h> ...
- 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+ ...
随机推荐
- react-native android 集成 react-native-baidu-map
记录下 遇到的问题,方便以后查看,参考 文章 https://www.jianshu.com/p/7ca4d7acb6d2 1. npm install react-native-baidu-map ...
- Java中,&&与&,||与|的区别
在java的逻辑运算符中,有这么四类:&&(短路与),&,|,||(短路或). &&和&都是表示与,区别是&&只要第一个条件不满足,后面 ...
- HTML一般标签
<title>无标题文档</title> </head> <body bgcolor="#33CC33" background=" ...
- pbft流程深层分析和解释(转)
<1>pbft五阶段请求解释 Request pre-prepare prepare commit 执行并reply (1)pre-prepare阶段: 主节点收到客户端请求, ...
- 解决error: only position independent executables (PIE) are supported
在Android.mk文件中添加以下内容 LOCAL_CFLAGS += -pie -fPIE LOCAL_LDFLAGS += -pie -fPIE 原帖地址:http://blog.csdn.ne ...
- C#格式化数值结果表(格式化字符串)
字符 说明 示例 输出 C 货币 string.Format("{0:C3}", 2) $2.000 D 十进制 string.Format("{0:D3}", ...
- KVM虚拟化技术(四)安装虚拟机
一.首先用比较简单的virt-manager来安装 # virt-manager 后面就是一般的安装系统流程了,这里不再复述 二.用virt-install命令行来安装 还是通过本地IOS文件来进行安 ...
- KVM虚拟化技术(三)KVM环境预配
一.平台操作系统安装 选择合适的操作系统,此处选用CentOS 7 系统可最小化安装,也可标准安装: 如果要远程连接,建议安装VNC-Server 将防火墙配置可通信,SELINUX设为permiss ...
- C++ 关于 CMFCPropertyGridCtrl 的使用方法 之二 (原创)
接上一节所讲,这一节咱们重点讲一下CMFCPropertyGridCtrl 所支持的数据表格的建立过程 在上一节中,咱们已经了解到了 CMFCPropertyGridCtrl 是要用到实例函数:Ad ...
- Win2012&Win2008双系统启动菜单设置
电脑最初安装的是XP,后来想升级操作系统,但XP里又有很多常用软件不想重装,于是装了一个Win2008 R2的双系统,安装好2008R2后,系统自动产生一个2008R2的启动菜单,可以选择进入2008 ...