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



A - Anton and Polyhedrons



#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
map<string,int> mp;
int n,sum;
string str;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);

mp.clear();
mp["Tetrahedron"]=4;
mp["Cube"]=6;
mp["Octahedron"]=8;
mp["Dodecahedron"]=12;
mp["Icosahedron"]=20;

cin>>n, sum=0;
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+10;

int n,m,x,y;
vector<P> A;
P L,R;


int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);

cin>>n;
while(n--)
{
cin>>x>>y;
A.pb(mk(x,y));
}

cin>>m;
L=mk(0,(int)2e9), R=mk(0,0);
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=0;
for(auto x:A)
{
int now=0;
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(2*(n-m));
while(k*(k+1)/2<n-m) k++;
cout<<m+k<<endl;
}
}


 



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