• Codeforces Round #644 (Div. 3)


    题目传送门

    A. Minimal Square

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    int a, b;
    void solve()
    {
        cin >> a >> b;
        if (a < b)
            swap(a, b);
        cout << max(a * a, b * b * 4) << endl;
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code

    B. Honest Coach

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    int n, a[60], ans;
    void solve()
    {
        cin >> n;
        ans = 1010;
        rep(i, 1, n) cin >> a[i];
        sort(a + 1, a + n + 1);
        rep(i, 1, n - 1) ans = min(ans, a[i + 1] - a[i]);
        cout << ans << endl;
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code

    C. Similar Pairs

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    int n, a[60], cnt, flag;
    void solve()
    {
        cin >> n;
        cnt = flag = 0;
        rep(i, 1, n) cin >> a[i];
        sort(a + 1, a + n + 1);
        a[n + 1] = 0;
        rep(i, 1, n)
        {
            if (a[i + 1] - a[i] == 1)
                flag = 1;
            if (a[i] % 2)
                cnt++;
        }
        if (flag || cnt % 2 == 0)
            puts("YES");
        else
            puts("NO");
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code

    D. Buying Shovels

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    ll n, k, ans;
    void solve()
    {
        cin >> n >> k;
        ans = 0;
        for (ll i = 1; i * i <= n; i++)
            if (n % i == 0)
            {
                if (i <= k)
                    ans = max(ans, i);
                if (n / i <= k)
                    ans = max(ans, n / i);
            }
        cout << n / ans << endl;
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code

    E. Polygon

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    ll n, mp[60][60];
    char f;
    int flag = 1;
    void solve()
    {
        cin >> n;
        flag = 1;
        rep(i, 1, n) rep(j, 1, n)
        {
            cin >> f;
            mp[i][j] = f == '1';
        }
        rep(i, 1, n) rep(j, 1, n) if (i != n && j != n && mp[i][j] && !(mp[i + 1][j] || mp[i][j + 1])) flag = 0;
        puts(flag ? "YES" : "NO");
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code

    F. Spy-string

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (register int i = a; i <= b; i++)
    
    int n, m;
    char mp[60][60], f;
    char ans[60];
    int flag = 1, cnt;
    void solve()
    {
        cin >> n >> m;
        flag = 1;
        rep(i, 1, n) rep(j, 1, m) cin >> mp[i][j];
        memset(ans, 0, sizeof(ans));
        rep(i, 1, m) ans[i] = mp[1][i];
        rep(i, 1, m) for (f = 'a'; f <= 'z'; f++)
        {
            ans[i] = f;
            cnt = 0;
            rep(j, 2, n)
            {
                cnt = 0;
                rep(k, 1, m) if (ans[k] != mp[j][k])
                    cnt++;
                if (cnt > 1)
                    break;
            }
            if (cnt < 2)
            {
                cout << ans + 1 << endl;
                return;
            }
            ans[i] = mp[1][i];
        }
        puts("-1");
    }
    int main()
    {
        int t = 1;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    View Code
  • 相关阅读:
    Guava学习笔记(4):Ordering犀利的比较器
    Guava学习笔记(3):复写的Object常用方法
    Guava学习笔记(1):Optional优雅的使用null
    [BZOJ1076][SCOI2008]奖励关
    [BZOJ1821][JSOI2010]部落划分
    [BZOJ1041]圆上的整点
    [Luogu2324]八数码难题
    [BZOJ1085][SCOI2005]骑士精神
    [BZOJ3109] [cqoi2013]新数独
    [LnOI2019]长脖子鹿省选模拟赛 东京夏日相会
  • 原文地址:https://www.cnblogs.com/likunhong/p/12955277.html
Copyright © 2020-2023  润新知