Codeforces Beta Round #76 (Div. 2 Only)

Codeforces Beta Round #76 (Div. 2 Only)

http://codeforces.com/contest/94

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 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ string s[];
string s1[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string str;
cin>>str;
for(int i=;i<;i++){
cin>>s[i];
}
for(int i=;i<;i++){
for(int j=;j<;j++){
s1[i]+=str[i*+j];
}
}
for(int i=;i<;i++){
for(int j=;j<;j++){
if(s1[i]==s[j]){
cout<<j;
break;
}
}
}
}

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 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int d[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string str;
int n;
cin>>n;
int u,v;
for(int i=;i<=n;i++){
cin>>u>>v;
d[u]++;
d[v]++;
}
for(int i=;i<=;i++){
if(d[i]!=){
cout<<"WIN"<<endl;
return ;
}
}
cout<<"FAIL"<<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 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
long long n,m,a,b;
cin>>n>>m>>a>>b;
int s,t;
s=a/m+(a%m!=);
t=b/m+(b%m!=);
if(m==){
cout<<;
return ;
}
if(b==n){
if(a%m==||s==t) cout<<;
else cout<<;
return ;
}
if((a%m==&&b%m==)||s==t) {cout<<;return ;}
if(a%m==||b%m==||s+==t||(b+)%m==a%m) cout<<;
else cout<<; }

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 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int cnt[];
int g[][]; int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
// std::ios::sync_with_stdio(false);
int n,w,m,i,j;
cin>>n>>w>>m;
for(i=;i<n;i++)cnt[i]=m;
int ii=;
for(i=;i<m;i++){
int k=n;
while(k>){
if(cnt[ii]==)
ii++;
cnt[ii]--;
k--;
g[ii][i]++;
}
}
for(i=;i<n;i++){
int cc=;
for(j=;j<m;j++)
if(g[i][j])
cc++;
if(cc>=)
break;
}
if(i<n)
cout<<"NO"<<endl;
else{
cout<<"YES"<<endl;
for(i=;i<m;i++){
bool f=;
for(j=;j<n;j++)
if(g[j][i]){
if(f)
f=;
else
cout<<" ";
printf("%d %.8lf",j+,(g[j][i]*(double)w)/m);
}
cout<<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 200005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int target;
int best = ;
int op1[], op2[], op3[], bop1[], bop2[], bop3[];
int reg[];
int N; void dfs(int lv){
if (lv>=best)return;
int i,j,k;
for(i=;i<N;i++) if (lv<best && reg[i]==target) {
best=lv;
for(j=;j<lv;j++) {
bop1[j]=op1[j], bop2[j]=op2[j], bop3[j]=op3[j];
}
return;
}
if (lv>=best-) return;
for(i=;i<N;i++) for(j=;j<N;j++) for (k=;k<=;k*=){
if (reg[i] + k*reg[j] > target) continue;
reg[N++] = reg[i] + k*reg[j];
op1[lv]=i; op2[lv]=k; op3[lv]=j;
dfs(lv+);
N--;
}
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>target;
reg[]=, reg[]=; N=;
dfs();
cout<<best<<endl;
int i;
for(i=;i<best;i++) {
cout<<"lea e" << (char)('a'++i)<<"x, [e" << (char)('a'+bop1[i])<<"x + " << bop2[i]<<"*e" << (char)('a'+bop3[i]) << "x]" << endl;
} }
上一篇:「暑期训练」「基础DP」 Piggy-Bank (HDU-1114)


下一篇:Codeforces Beta Round #77 (Div. 2 Only)