Codeforces Beta Round #73 (Div. 2 Only)

时间:2023-11-18 12:13:44

Codeforces Beta Round #73 (Div. 2 Only)

http://codeforces.com/contest/88

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 1000006
#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<pair<int,string>,pii> ppp;
typedef unsigned long long ull; string s[]={"C","C#","D","D#","E","F","F#","G","G#","A","B","H"},a,b,c;
int x[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin >> a >> b >> c;
for(int i=;i<;i++){
if(a==s[i] || b==s[i] || c==s[i])x[i]=;
}
for(int i=;i<;i++){
if(x[i]){
if(x[(i+)%] && x[(i+)%]){
cout << "major" << endl;
return ;
}
if(x[(i+)%] && x[(i+)%]){
cout << "minor" << endl;
return ;
}
}
}
cout << "strange" << 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 1000006
#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<pair<int,string>,pii> ppp;
typedef unsigned long long ull; string str;
map<char,int>mp;
string s[];
map<char,int>book;
vector<pii>ve; double dis(int a,int b,int c,int d){
return sqrt(sqr(a-c)+sqr(b-d));
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n,m,len;
double x;
cin>>n>>m>>x;
for(int i=;i<n;i++){
cin>>s[i];
for(int j=;j<m;j++){
mp[s[i][j]]=;
if(s[i][j]=='S') ve.pb(make_pair(i,j));
}
}
cin>>len>>str;
int ans=;
pii tmp;
double dist;
for(int k=;k<ve.size();k++){
for(int i=;i<n;i++){
for(int j=;j<m;j++){
dist=dis(ve[k].first,ve[k].second,i,j);
if(dist<=x) {
book[s[i][j]]=;
}
}
}
}
int i;
for(i=;i<len;i++){
if((str[i]>='A'&&str[i]<='Z'&&!mp[str[i]+])||(str[i]>='A'&&str[i]<='Z'&&!mp['S'])||(str[i]>='a'&&str[i]<='z'&&!mp[str[i]])) {
ans=;
break;
}
else if(str[i]>='A'&&str[i]<='Z'&&mp['S']){
if(!book[str[i]+]) ans++;
}
}
if(i==len&&ans==) cout<<<<endl;
else if(!ans) cout<<-<<endl;
else cout<<ans<<endl;
}

C

gcd

 #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 1000006
#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<pair<int,string>,pii> ppp;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int a,b;
cin >> a>>b;
cout <<((abs(a/__gcd(a,b)-b/__gcd(a,b))==)?"Equal":(a<b?"Dasha":"Masha"))<<endl;
}

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 1000006
#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<double,double>pdd;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull; map<string,int>mp;
int n,cou;
string a,b,c;
void solve()
{
cin>>b;
int ans=;
string d="";
for(int i=; i<b.size(); i++)
{
if(b[i]=='&') ans--;
else if(b[i]=='*') ans++;
else d+=b[i];
}
cou=mp[d];
if(cou>) cou+=ans;
else cou=;
b.clear();
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
mp["void"]=;
cin>>n;
while(n--)
{
cin>>a;
if(a=="typedef")
{
solve();
cin>>c;
mp[c]=cou;
c.clear();
}
else if(a=="typeof")
{
solve();
if(--cou<) cout<<"errtype"<<endl;
else
{
cout<<"void";
for(int i=; i<cou; i++) cout<<"*";
cout<<endl;
}
}
a.clear();
}
}

E

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

 #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 maxn 100005
typedef long long ll;
typedef unsigned long long ull;
const ull MOD=;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int ans[maxn],sg[maxn],mex[maxn]; void getsg(int n){ for(int i=;i*(i+)/<=n;i++){
if((*n)%i==){
int t=*n/i-i+;
if((t&)||t<) continue;
t/=;
mex[sg[t-+i]^sg[t-]]=n;
if((sg[t-+i]^sg[t-])==)
if(ans[n]==-)
ans[n]=i;
}
}
sg[n]=-;
for(int i=;;i++){
if(mex[i]!=n){
sg[n]=i;
break;
}
}
sg[n]^=sg[n-];
return ;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
memset(ans,-,sizeof(ans));
for(int i=;i<=n;i++){
getsg(i);
}
cout<<ans[n]<<endl;
}