修改密码

【2024周赛课程】内部周赛训练精讲课程

成品课程

陈远龙老师主讲 & 答疑

未购买 · 可先试学5节课

课程目录展开/折叠

2024.12.22-Contest#38-每周六模拟比赛题目讲解

播放快捷键

播放/暂停:空格(或鼠标单击)      全屏:F(或鼠标双击)      退出全屏:Esc

快进10 / 30 / 60秒:方向键→ / Ctrl + 方向键→ / Shift + 方向键→

快退10 / 30 / 60秒:方向键← / Ctrl + 方向键← / Shift + 方向键←

本节课讲解配套PPT&板书:

比赛题目参考源代码

源代码下载:2024.12.22-Contest#38参考源代码下载

1. C1149-二进制分类-1
#include <bits/stdc++.h>
using namespace std;

bool judge(int a)
{
    int cnt[2] = {0};
    while (a)
    {
        cnt[a % 2]++;
        a /= 2;
    }
    // cout << cnt[1] << ' ' << cnt[0] << endl;
    if (cnt[1] > cnt[0]) 
        return true;
    return false;
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i ++)
    {
        if (judge(i)) ans ++;
    }
    cout << ans << ' ' << (n - ans);

    return 0;
}
2. C1150-计算三角形面积-1
#include <bits/stdc++.h>
using namespace std;

int main()
{
    float x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    float a = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    float b = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
    float c = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) *(y1 - y3));
    // cout << a << ' ' << b << ' ' << c << endl;
    float l = max(max(a, b), c);
    if (a + b + c - l > l)
    {
        float p = (a + b + c) / 2;
        float s = sqrt(p * (p - a) * (p - b) * (p - c));
        cout << fixed << setprecision(2) << s;
    }
    else
        cout << -1;

    return 0;
} 
3. C1151-车厢重组-1
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 10005;
int a[MAXN];

typedef long long ll;
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[i];

    ll ans = 0;
    for (int i = n - 1; i > 0; i --)
    {
        bool flag = false;
        for (int j = 0; j < i; j ++)
        {
            if (a[j] > a[j + 1])
            {
                swap(a[j], a[j + 1]);
                ans ++;
                flag = true;
            }
        }
        if (!flag) break;
    }

    cout << ans;
    return 0; 
}
4. C1151-车厢重组-2
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 10005;
int a[MAXN];

typedef long long ll;
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[i];

    ll ans = 0;
    for (int i = 0; i < n - 1; i ++)
    {
        bool flag = false;
        for (int j = n - 1; j > i; j --)
        {
            if (a[j] < a[j - 1])
            {
                swap(a[j], a[j - 1]);
                ans ++;
                flag = true;
            }
        }
        if (!flag) break;
    }

    cout << ans;
    return 0; 
}
5. C1152-合并生物-1
#include <bits/stdc++.h>
using namespace std;

int n;
const int MAXN = 1e4 + 5;
int a[MAXN];

/*
bool cmp(int a, int b)
{
    return a > b;
}
*/

int main()
{
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[i];
    sort(a, a + n, greater<int>());
    // sort(a, a + n);
    // sort(a, a + n, cmp);
    double ans = a[0];
    for (int i = 1; i < n; i ++)
    {
        ans = 2 * sqrt(ans * a[i]);
    }
    cout << fixed << setprecision(3) << ans << endl;

    return 0;
}
6. C1152-合并生物-2
#include <bits/stdc++.h>
using namespace std;

int n;
const int MAXN = 1e4 + 5;
int a[MAXN];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[i];
    sort(a, a + n); // 从小到大排序 
    double ans = a[n - 1];
    for (int i = n - 2; i >= 0; i --)
    {
        ans = 2 * sqrt(ans * a[i]);
    }
    cout << fixed << setprecision(3) << ans << endl;

    return 0;
}

本节课答疑

建议大家有问题先通过AI答疑(比如:DeepSeek 等),AI时代需要学会使用AI辅助学习

陈远龙老师视频讲解:如何使用DeepSeek进行答疑?

通过AI未能获得满意解答的,可以联系陈远龙老师答疑

目录