Codeforces 785 - A/B/C/D/E - (Undone)

时间:2021-09-10 13:00:41

链接:https://codeforces.com/contest/785


A - Anton and Polyhedrons

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+;
map<string,int> mp;
int n,sum;
string str;
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); mp.clear();
mp["Tetrahedron"]=;
mp["Cube"]=;
mp["Octahedron"]=;
mp["Dodecahedron"]=;
mp["Icosahedron"]=; cin>>n, sum=;
while(n--) cin>>str, sum+=mp[str];
cout<<sum<<endl;
}

B - Anton and Classes

#include<bits/stdc++.h>
#define pb(x) push_back(x)
using namespace std;
typedef pair<int,int> P;
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int MAX=2e5+; int n,m,x,y;
vector<P> A;
P L,R; int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n;
while(n--)
{
cin>>x>>y;
A.pb(mk(x,y));
} cin>>m;
L=mk(,(int)2e9), R=mk(,);
while(m--)
{
cin>>x>>y;
if(y<L.se) L=mk(x,y);
if(x>R.fi) R=mk(x,y);
}
// cout<<L.fi<<" "<<L.se<<endl;
// cout<<R.fi<<" "<<R.se<<endl; int res=;
for(auto x:A)
{
int now=;
if(x.fi>L.se) now=max(now,x.fi-L.se);
if(x.se<R.fi) now=max(now,R.fi-x.se);
res=max(res,now);
}
cout<<res<<endl;
}

C - Anton and Fairy Tale - [算术题]

#include<bits/stdc++.h>
using namespace std;
typedef long long ll; ll n,m; int main()
{
cin>>n>>m;
if(n<=m) cout<<n<<endl;
else
{
ll k=sqrt(*(n-m));
while(k*(k+)/<n-m) k++;
cout<<m+k<<endl;
}
}

D - Anton and School - 2 - [范德蒙德恒等式][快速幂+逆元]