C23本部国庆集训测试

Done IOI Start at: 2023-10-5 13:30 2 hour(s) Host: 10

卡片排序

#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin >> t;
    while(t--) {
        char s1, s2, s3;
        getchar();
        scanf("%c %c %c", &s1, &s2, &s3);
        if(s1 == 'J' || s2 == 'Q' || s3 == 'K')cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}

好孩子

#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        int a[10];
        for(int i = 0; i < n; i++)cin >> a[i];
        sort(a, a + n);
        a[0]++;
        long long sum = 1;
        for(int i = 0; i < n; i++)sum *= a[i];
        cout << sum << endl;
    }
}

打靶

#include<bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin >> t;
    while(t--) {
        char c;
        int num = 0, i, j;
        for(i = 1; i <= 10; i++)
            for(j = 1; j <= 10; j++) {
                cin >> c;
                if(c == 'X') {
                    num += min(min(i, 10 - i + 1), min(j, 10 - j + 1));

                }
            }
        cout << num << endl;
    }
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

const int MAX = 200007;
const int MOD = 1000000007;

int score[10][10] = {
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 2, 2, 2, 2, 2, 2, 2, 2, 1},
    {1, 2, 3, 3, 3, 3, 3, 3, 2, 1},
    {1, 2, 3, 4, 4, 4, 4, 3, 2, 1},
    {1, 2, 3, 4, 5, 5, 4, 3, 2, 1},
    {1, 2, 3, 4, 5, 5, 4, 3, 2, 1},
    {1, 2, 3, 4, 4, 4, 4, 3, 2, 1},
    {1, 2, 3, 3, 3, 3, 3, 3, 2, 1},
    {1, 2, 2, 2, 2, 2, 2, 2, 2, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
};

void solve() {
    int ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            char c;
            cin >> c;
            if (c == 'X') {
                ans += score[i][j];
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    //取消同步,使得cin速度接近于scanf
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int tt;
    cin >> tt;
    for (int i = 1; i <= tt; i++) {
        solve();
    }
    return 0;
}

最大的K

#include<bits/stdc++.h>
using namespace std;
int T, n;
int main() {
    for(cin >> T; T--;) cin >> n,
            cout << (1 << (int)(log2(n))) - 1 << "\n";
    return 0;
}
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    int t;
    cin >> t;
    for(int cs = 1; cs <= t; cs++) {
        ll n;
        cin >> n;
        ll p = 1;
        while(p <= n)p <<= 1;
        cout << ((p >> 1) - 1) << endl;
    }
    return 0;
}

橡皮擦

#include<bits/stdc++.h>
using namespace std;
char s[200005];
int main() {
    int t, n, k, ans, i;
    scanf("%d", &t);
    while (t--) {
        scanf("%d%d", &n, &k), ans = 0;

        scanf("%s", s);
        for (i = 0; i < n; i++)s[i] == 'B' ? ans++, i += k - 1 : 1;
        printf("%d\n", ans);
    }
    return 0;
}

水箱

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int t, n, x;
    cin >> t;
    while(t-- && cin >> n >> x) {
        vector<int>a(n);
        for(auto &i : a)cin >> i;
        int l(1), r(3e9);
        while(r > l + 1) {
            int m = (l + r ) >> 1, d = 0;
            for(int i : a)d += m - min(m, i);
            d <= x ? l = m : r = m;
        }
        cout << l << '\n';
    }
    return 0;
}

数论难题

#include <bits/stdc++.h>
using namespace std;


int a[15];
int main() {
    int t, cnt = 1;;
    cin >> t;
    while(t--) {
        int sum = 0;
        for(int i = 1; i <= 10; i++)
            scanf("%d", &a[i]), sum += a[i];
        sort(a + 1, a + 1 + 10);

        sum /= 4;
        int x3 = sum - a[1] - a[10];
        int x1 = a[2] - x3;
        int x2 = a[1] - x1;
        int x5 = a[9] - x3;
        int x4 = a[10] - x5;

        printf("Case %d: ", cnt++);
        printf("%d %d %d %d %d\n", x1, x2, x3, x4, x5);
    }
    return 0;
}
Status
Done
Rule
IOI
Problem
7
Start at
2023-10-5 13:30
End at
2023-10-5 15:30
Duration
2 hour(s)
Host
Partic.
10