zoukankan      html  css  js  c++  java
  • Codeforces 785

    链接: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 - [范德蒙德恒等式][快速幂+逆元]

  • 相关阅读:
    搬家
    围棋程序
    图论----基础知识
    贪心算法
    944. 删列造序
    1221. 分割平衡字符串
    面试题 01.01. 判定字符是否唯一
    剑指 Offer 10- II. 青蛙跳台阶问题
    面试题 16.11. 跳水板
    1137. 第 N 个泰波那契数
  • 原文地址:https://www.cnblogs.com/dilthey/p/10692825.html
Copyright © 2011-2022 走看看