zoukankan      html  css  js  c++  java
  • Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only)

    http://codeforces.com/contest/88

    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 1000006
     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<pair<int,string>,pii> ppp;
    15 typedef unsigned long long ull;
    16 
    17 string s[12]={"C","C#","D","D#","E","F","F#","G","G#","A","B","H"},a,b,c;
    18 int x[12];
    19 
    20 int main(){
    21     #ifndef ONLINE_JUDGE
    22      //   freopen("input.txt","r",stdin);
    23     #endif
    24     std::ios::sync_with_stdio(false);
    25     cin >> a >> b >> c;
    26     for(int i=0;i<12;i++){
    27         if(a==s[i] || b==s[i] || c==s[i])x[i]=1;
    28     }
    29     for(int i=0;i<12;i++){
    30          if(x[i]){
    31             if(x[(i+4)%12] && x[(i+7)%12]){
    32                 cout << "major" << endl;
    33                 return 0;
    34             }
    35             if(x[(i+3)%12] && x[(i+7)%12]){
    36                 cout << "minor" << endl;
    37                 return 0;
    38             }
    39          }
    40     }
    41     cout << "strange" << endl;
    42 }
    View Code

    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 1000006
     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<pair<int,string>,pii> ppp;
    15 typedef unsigned long long ull;
    16 
    17 string str;
    18 map<char,int>mp;
    19 string s[55];
    20 map<char,int>book;
    21 vector<pii>ve;
    22 
    23 double dis(int a,int b,int c,int d){
    24     return sqrt(sqr(a-c)+sqr(b-d));
    25 }
    26 
    27 int main(){
    28     #ifndef ONLINE_JUDGE
    29      //   freopen("input.txt","r",stdin);
    30     #endif
    31     std::ios::sync_with_stdio(false);
    32     int n,m,len;
    33     double x;
    34     cin>>n>>m>>x;
    35     for(int i=0;i<n;i++){
    36         cin>>s[i];
    37         for(int j=0;j<m;j++){
    38             mp[s[i][j]]=1; 
    39             if(s[i][j]=='S') ve.pb(make_pair(i,j));
    40         }
    41     }
    42     cin>>len>>str;
    43     int ans=0;
    44     pii tmp;
    45     double dist;
    46     for(int k=0;k<ve.size();k++){
    47         for(int i=0;i<n;i++){
    48             for(int j=0;j<m;j++){
    49                 dist=dis(ve[k].first,ve[k].second,i,j);
    50                 if(dist<=x)    {
    51                     book[s[i][j]]=1;
    52                 }
    53             }
    54         }
    55     }
    56     int i;
    57     for(i=0;i<len;i++){
    58         if((str[i]>='A'&&str[i]<='Z'&&!mp[str[i]+32])||(str[i]>='A'&&str[i]<='Z'&&!mp['S'])||(str[i]>='a'&&str[i]<='z'&&!mp[str[i]])) {
    59             ans=0; 
    60             break;
    61         }
    62         else if(str[i]>='A'&&str[i]<='Z'&&mp['S']){
    63             if(!book[str[i]+32]) ans++;
    64         }
    65     }
    66     if(i==len&&ans==0) cout<<0<<endl;
    67     else if(!ans) cout<<-1<<endl;
    68     else cout<<ans<<endl;
    69 }
    View Code

    C

    gcd

     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 1000006
     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<pair<int,string>,pii> ppp;
    15 typedef unsigned long long ull;
    16 
    17 
    18 int main(){
    19     #ifndef ONLINE_JUDGE
    20      //   freopen("input.txt","r",stdin);
    21     #endif
    22     std::ios::sync_with_stdio(false);
    23     int a,b;
    24     cin >> a>>b;
    25     cout <<((abs(a/__gcd(a,b)-b/__gcd(a,b))==1)?"Equal":(a<b?"Dasha":"Masha"))<<endl;
    26 }
    View Code

    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 1000006
     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<double,double>pdd;
    15 typedef pair<pair<int,string>,pii> ppp;
    16 typedef unsigned long long ull;
    17 
    18 map<string,int>mp;
    19 int n,cou;
    20 string a,b,c;
    21 void solve()
    22 {
    23     cin>>b;
    24     int ans=0;
    25     string d="";
    26     for(int i=0; i<b.size(); i++)
    27     {
    28         if(b[i]=='&') ans--;
    29         else if(b[i]=='*') ans++;
    30         else d+=b[i];
    31     }
    32     cou=mp[d];
    33     if(cou>0) cou+=ans;
    34     else cou=0;
    35     b.clear();
    36 }
    37 
    38 
    39 int main(){
    40     #ifndef ONLINE_JUDGE
    41      //   freopen("input.txt","r",stdin);
    42     #endif
    43     std::ios::sync_with_stdio(false);
    44     mp["void"]=1;
    45     cin>>n;
    46     while(n--)
    47     {
    48         cin>>a;
    49         if(a=="typedef")
    50         {
    51             solve();
    52             cin>>c;
    53             mp[c]=cou;
    54             c.clear();
    55         }
    56         else if(a=="typeof")
    57         {
    58             solve();
    59             if(--cou<0) cout<<"errtype"<<endl;
    60             else
    61             {
    62                 cout<<"void";
    63                 for(int i=0; i<cou; i++) cout<<"*";
    64                 cout<<endl;
    65             }
    66         }
    67         a.clear();
    68     }
    69 }
    View Code

    E

    sg函数(照着AC代码打的,没有完全理解)

     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 maxn 100005
     7 typedef long long ll;
     8 typedef unsigned long long ull;
     9 const ull MOD=257;
    10 /*#ifndef ONLINE_JUDGE
    11         freopen("1.txt","r",stdin);
    12 #endif */
    13 
    14 int ans[maxn],sg[maxn],mex[maxn];
    15 
    16 void getsg(int n){
    17 
    18     for(int i=2;i*(i+1)/2<=n;i++){
    19         if((2*n)%i==0){
    20             int t=2*n/i-i+1;
    21             if((t&1)||t<0) continue;
    22             t/=2;
    23             mex[sg[t-1+i]^sg[t-1]]=n;
    24             if((sg[t-1+i]^sg[t-1])==0)
    25                 if(ans[n]==-1)
    26                     ans[n]=i;
    27         }
    28     }
    29     sg[n]=-1;
    30     for(int i=0;;i++){
    31         if(mex[i]!=n){
    32             sg[n]=i;
    33             break;
    34         }
    35     }
    36     sg[n]^=sg[n-1];
    37     return ;
    38 }
    39 
    40 int main(){
    41     #ifndef ONLINE_JUDGE
    42      //   freopen("1.txt","r",stdin);
    43     #endif
    44     std::ios::sync_with_stdio(false);
    45     int n;
    46     cin>>n;
    47     memset(ans,-1,sizeof(ans));
    48     for(int i=3;i<=n;i++){
    49         getsg(i);
    50     }
    51     cout<<ans[n]<<endl;
    52 }
    View Code
  • 相关阅读:
    [ Algorithm ] N次方算法 N Square 动态规划解决
    [ Algorithm ] LCS 算法 动态规划解决
    sql server全文索引使用中的小坑
    关于join时显示no join predicate的那点事
    使用scvmm 2012的动态优化管理群集资源
    附加数据库后无法创建发布,error 2812 解决
    浅谈Virtual Machine Manager(SCVMM 2012) cluster 过载状态检测算法
    windows 2012 r2下安装sharepoint 2013错误解决
    sql server 2012 数据引擎任务调度算法解析(下)
    sql server 2012 数据引擎任务调度算法解析(上)
  • 原文地址:https://www.cnblogs.com/Fighting-sh/p/10498499.html
Copyright © 2011-2022 走看看