zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 73 (Rated for Div. 2)

    Educational Codeforces Round 73 (Rated for Div. 2)

    A. 2048 Game

    • __思路:水题 __

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int q, n;
    ll x, sum;
    bool flag;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> q;
        while (q -- ){
            sum = 0;
            cin >> n;
            for (int i = 1; i <= n; i ++ ){
                cin >> x;
                if (x <= 2048)
                    sum += x;
            }
            if (sum >= 2048)
                cout << "YES
    ";
            else
                cout << "NO
    ";
        }
        return 0;
    }
    

    B. Knights

    • 思路:依次间隔构造即可

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const int N = 110;
    
    int n;
    char mp[N][N];
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> n;
        for (int i = 1; i <= n; i ++ ){
            if (i & 1){
                for (int j = 1; j <= n; j ++ ){
                    if (j & 1)
                        mp[i][j] = 'W';
                    else
                        mp[i][j] = 'B';
                }
            }
            else{
                for (int j = 1; j <= n; j ++ ){
                    if (j & 1)
                        mp[i][j] = 'B';
                    else
                        mp[i][j] = 'W';
                }
            }
        }
        for (int i = 1; i <= n; i ++ ){
            for (int j = 1; j <= n; j ++ )
                cout << mp[i][j];
            cout << "
    ";
        }
        return 0;
    }
    

    C. Perfect Team

    • 思路:思维题

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    int q, c, m, x, min_;
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> q;
        while (q -- ){
            cin >> c >> m >> x;
            min_ = min(c, m);
            if (c - min_ + m - min_ + x < min_)
                cout << x + (c - x + m - x) / 3 << "
    ";
            else
                cout << min_ << "
    ";
        }
        return 0;
    }
    

    D. Make The Fence Great Again

    • 思路:线性dp

    • AC代码


    #include <algorithm>
    #include <iomanip>
    #include <iostream>
    #include <map>
    #include <math.h>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdio.h>
    #include <string.h>
    #include <string>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    
    ll mult_mod(ll x, ll y, ll mod){
        return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
    }
    
    ll pow_mod(ll a, ll b, ll p){
        ll res = 1;
        while (b){
            if (b & 1)
                res = mult_mod(res, a, p);
            a = mult_mod(a, a, p);
            b >>= 1;
        }
        return res % p;
    }
    
    ll gcd(ll a, ll b){
        return b ? gcd(b, a % b) : a;
    }
    
    const int N = 3e5 + 10;
    const ll INF = 2e18;
    
    int q, n;
    int a[N], b[N];
    ll dp[N][3];
    
    int main(){
    #ifndef ONLINE_JUDGE
        freopen("my_in.txt", "r", stdin);
    #endif
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin >> q;
        while (q -- ){
            cin >> n;
            for (int i = 1; i <= n; i ++ ){
                cin >> a[i] >> b[i];
                dp[i][0] = dp[i][1] = dp[i][2] = INF;
            }
            dp[1][0] = 0, dp[1][1] = b[1], dp[1][2] = 2 * b[1];
            for (int i = 2; i <= n; i ++ )
                for (int j = 0; j < 3; j ++ )
                    for (int k = 0; k < 3; k ++ )
                        if (a[i] + k != a[i - 1] + j)
                            dp[i][k] = min(dp[i][k], dp[i - 1][j] + k * b[i]);
            cout << min(dp[n][0], min(dp[n][1], dp[n][2])) << "
    ";
        }
        return 0;
    }
    
  • 相关阅读:
    异步任务AsyncTask
    巧用TextView实现分隔线
    android系统的常用权限
    浅析对话框AlertDialog
    LinearLayout中的layout_weight属性详解
    CLOB大数据对象
    模糊查询demo
    ES6 箭头函数
    ES6中数组求和,求平均数方法( reduce )
    ES6中数组方法( every 和 some )
  • 原文地址:https://www.cnblogs.com/Misuchii/p/11801524.html
Copyright © 2011-2022 走看看