Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only)
http://codeforces.com/contest/94
A
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define eb emplace_back 8 #define maxn 200005 9 #define eps 1e-8 10 #define pi acos(-1.0) 11 #define rep(k,i,j) for(int k=i;k<j;k++) 12 typedef long long ll; 13 typedef pair<int,int> pii; 14 typedef pair<char,int> pci; 15 typedef pair<pair<int,string>,pii> ppp; 16 typedef unsigned long long ull; 17 const long long MOD=1e9+9; 18 /*#ifndef ONLINE_JUDGE 19 freopen("1.txt","r",stdin); 20 #endif */ 21 22 23 string s[15]; 24 string s1[15]; 25 26 int main(){ 27 #ifndef ONLINE_JUDGE 28 // freopen("1.txt","r",stdin); 29 #endif 30 std::ios::sync_with_stdio(false); 31 string str; 32 cin>>str; 33 for(int i=0;i<10;i++){ 34 cin>>s[i]; 35 } 36 for(int i=0;i<8;i++){ 37 for(int j=0;j<10;j++){ 38 s1[i]+=str[i*10+j]; 39 } 40 } 41 for(int i=0;i<8;i++){ 42 for(int j=0;j<10;j++){ 43 if(s1[i]==s[j]){ 44 cout<<j; 45 break; 46 } 47 } 48 } 49 }
B
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define eb emplace_back 8 #define maxn 200005 9 #define eps 1e-8 10 #define pi acos(-1.0) 11 #define rep(k,i,j) for(int k=i;k<j;k++) 12 typedef long long ll; 13 typedef pair<int,int> pii; 14 typedef pair<char,int> pci; 15 typedef pair<pair<int,string>,pii> ppp; 16 typedef unsigned long long ull; 17 const long long MOD=1e9+9; 18 /*#ifndef ONLINE_JUDGE 19 freopen("1.txt","r",stdin); 20 #endif */ 21 22 int d[15]; 23 24 25 int main(){ 26 #ifndef ONLINE_JUDGE 27 // freopen("1.txt","r",stdin); 28 #endif 29 std::ios::sync_with_stdio(false); 30 string str; 31 int n; 32 cin>>n; 33 int u,v; 34 for(int i=1;i<=n;i++){ 35 cin>>u>>v; 36 d[u]++; 37 d[v]++; 38 } 39 for(int i=1;i<=5;i++){ 40 if(d[i]!=2){ 41 cout<<"WIN"<<endl; 42 return 0; 43 } 44 } 45 cout<<"FAIL"<<endl; 46 }
C
找规律
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define eb emplace_back 8 #define maxn 200005 9 #define eps 1e-8 10 #define pi acos(-1.0) 11 #define rep(k,i,j) for(int k=i;k<j;k++) 12 typedef long long ll; 13 typedef pair<int,int> pii; 14 typedef pair<char,int> pci; 15 typedef pair<pair<int,string>,pii> ppp; 16 typedef unsigned long long ull; 17 const long long MOD=1e9+7; 18 /*#ifndef ONLINE_JUDGE 19 freopen("1.txt","r",stdin); 20 #endif */ 21 22 int main(){ 23 #ifndef ONLINE_JUDGE 24 // freopen("1.txt","r",stdin); 25 #endif 26 std::ios::sync_with_stdio(false); 27 long long n,m,a,b; 28 cin>>n>>m>>a>>b; 29 int s,t; 30 s=a/m+(a%m!=0); 31 t=b/m+(b%m!=0); 32 if(m==1){ 33 cout<<1; 34 return 0; 35 } 36 if(b==n){ 37 if(a%m==1||s==t) cout<<1; 38 else cout<<2; 39 return 0; 40 } 41 if((a%m==1&&b%m==0)||s==t) {cout<<1;return 0;} 42 if(a%m==1||b%m==0||s+1==t||(b+1)%m==a%m) cout<<2; 43 else cout<<3; 44 45 }
D
贪心
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define eb emplace_back 8 #define maxn 200005 9 #define eps 1e-8 10 #define pi acos(-1.0) 11 #define rep(k,i,j) for(int k=i;k<j;k++) 12 typedef long long ll; 13 typedef pair<int,int> pii; 14 typedef pair<char,int> pci; 15 typedef pair<pair<int,string>,pii> ppp; 16 typedef unsigned long long ull; 17 const long long MOD=1e9+7; 18 /*#ifndef ONLINE_JUDGE 19 freopen("1.txt","r",stdin); 20 #endif */ 21 22 int cnt[105]; 23 int g[105][105]; 24 25 int main(){ 26 #ifndef ONLINE_JUDGE 27 // freopen("1.txt","r",stdin); 28 #endif 29 // std::ios::sync_with_stdio(false); 30 int n,w,m,i,j; 31 cin>>n>>w>>m; 32 for(i=0;i<n;i++)cnt[i]=m; 33 int ii=0; 34 for(i=0;i<m;i++){ 35 int k=n; 36 while(k>0){ 37 if(cnt[ii]==0) 38 ii++; 39 cnt[ii]--; 40 k--; 41 g[ii][i]++; 42 } 43 } 44 for(i=0;i<n;i++){ 45 int cc=0; 46 for(j=0;j<m;j++) 47 if(g[i][j]) 48 cc++; 49 if(cc>=3) 50 break; 51 } 52 if(i<n) 53 cout<<"NO"<<endl; 54 else{ 55 cout<<"YES"<<endl; 56 for(i=0;i<m;i++){ 57 bool f=1; 58 for(j=0;j<n;j++) 59 if(g[j][i]){ 60 if(f) 61 f=0; 62 else 63 cout<<" "; 64 printf("%d %.8lf",j+1,(g[j][i]*(double)w)/m); 65 } 66 cout<<endl; 67 } 68 } 69 70 }
E
暴力搜索
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define eb emplace_back 8 #define maxn 200005 9 #define eps 1e-8 10 #define pi acos(-1.0) 11 #define rep(k,i,j) for(int k=i;k<j;k++) 12 typedef long long ll; 13 typedef pair<int,int> pii; 14 typedef pair<char,int> pci; 15 typedef pair<pair<int,string>,pii> ppp; 16 typedef unsigned long long ull; 17 const long long MOD=1e9+7; 18 /*#ifndef ONLINE_JUDGE 19 freopen("1.txt","r",stdin); 20 #endif */ 21 22 int target; 23 int best = 10; 24 int op1[15], op2[15], op3[15], bop1[15], bop2[15], bop3[15]; 25 int reg[15]; 26 int N; 27 28 void dfs(int lv){ 29 if (lv>=best)return; 30 int i,j,k; 31 for(i=0;i<N;i++) if (lv<best && reg[i]==target) { 32 best=lv; 33 for(j=0;j<lv;j++) { 34 bop1[j]=op1[j], bop2[j]=op2[j], bop3[j]=op3[j]; 35 } 36 return; 37 } 38 if (lv>=best-1) return; 39 for(i=0;i<N;i++) for(j=0;j<N;j++) for (k=1;k<=8;k*=2){ 40 if (reg[i] + k*reg[j] > target) continue; 41 reg[N++] = reg[i] + k*reg[j]; 42 op1[lv]=i; op2[lv]=k; op3[lv]=j; 43 dfs(lv+1); 44 N--; 45 } 46 } 47 48 int main(){ 49 #ifndef ONLINE_JUDGE 50 // freopen("1.txt","r",stdin); 51 #endif 52 std::ios::sync_with_stdio(false); 53 cin>>target; 54 reg[0]=1, reg[1]=0; N=2; 55 dfs(0); 56 cout<<best<<endl; 57 int i; 58 for(i=0;i<best;i++) { 59 cout<<"lea e" << (char)('a'+2+i)<<"x, [e" << (char)('a'+bop1[i])<<"x + " << bop2[i]<<"*e" << (char)('a'+bop3[i]) << "x]" << endl; 60 } 61 62 }
posted on 2019-03-11 20:25 Fighting_sh 阅读(167) 评论(0) 编辑 收藏 举报