其他分享
首页 > 其他分享> > 2021 Jiangsu Collegiate Programming Contest

2021 Jiangsu Collegiate Programming Contest

作者:互联网

A. Spring Couplets

#include <bits/stdc++.h>
using namespace std;
string a[30], b[30];
int n;
bool check()
{
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i].back() > '2' && b[i].back() > '2') return false;
        if (a[i].back() < '3' && b[i].back() < '3') return false;
    }
    if (a[n - 1].back() < '3' || b[n - 1].back() > '2') return false;
    return true;
}
int main()
{
    int cass;
    for (cin >> cass; cass; cass--)
    {
        cin >> n;
        for (int i = 0; i < n; i++) cin >> a[i];
        for (int i = 0; i < n; i++) cin >> b[i];
        cout << (check() ? "YES" : "NO") << "\n";
     }
    return 0;
}
View Code

B. Among Us

C. Magical Rearrangement

I. Fake Walsh Transform

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int cass;
    for (cin >> cass; cass; cass--)
    {
        ll n, m;
        cin >> n >> m;
        if (n == 1)
        {
            cout << (m == 1 ? "2" : "1") << endl;
            continue;
        }
        ll sum = 1;
        while (n--) sum <<= 1;
        cout << sum - (m ? 1 : 0) << endl;
    }
    return 0;
}
View Code

K. Longest Continuous 1

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[50];
int main()
{
    a[0] = 1;
    for (int i = 1; i <= 30; i++) a[i] = (i - 1) * (2 << (i - 1)) + 2;
    int cass, k;
    for (cin >> cass; cass; cass--)
    {
        cin >> k;
        for (int i = 0; i <= 30; i++)
        {
            if (a[i] >= k)
            {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}
View Code

标签:Jiangsu,Contest,int,ll,Programming,cin,long,back,cass
来源: https://www.cnblogs.com/ltzmgby/p/15772407.html