2025ICPC南昌邀请赛题解

出题组:XDU & WHU。
第一题是主办方加的签到题。邀请赛榜单8题金,6题手快可以银,五题铜,榜单:ICPC南昌邀请赛榜单


A. Nezha Naohai

只要不是想当然都乘起来应该不会错的, ( a + b + c ) × d (a+b+c) \times d (a+b+c)×d

#include <bits/stdc++.h>
#define x first
#define y second
#define int long long

using namespace std;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const int N = 100010, M = N * 2, mod = 1e9 + 7, P = 131;

void solve()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a + b + c) * d << "\n";
}

signed main()
{
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}
K. Rotation

一开始读成了操作一是当前这个不动,喜提wa。
这道题应该这样来看,先执行操作一,将所有的统一成一个方向再执行操作二。
所以先按顺时针统一方向,这一步需要mp[(i + 1) % 4] + 2 * mp[(i + 2) % 4] + 3 * mp[(i + 3) % 4]步操作,最后再将统一的方法执行操作二转到方向0。

#include <bits/stdc++.h>
#define x first
#define y second
#define int long long

using namespace std;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const int N = 1000010, M = N * 2, mod = 1e9 + 7, P = 131;
int n;
int a[N];

void solve()
{
    cin >> n;
    map<int, int> mp;
    for (int i = 1; i <= n; i++)
        cin >> a[i], mp[a[i]]++;
    int res = 1e18;
    for (int i = 0; i < 4; i++)
    {
        int s = mp[(i + 1) % 4] + 2 * mp[(i + 2) % 4] + 3 * mp[(i + 3) % 4];
        int j = (i + s) % 4;
        if (j != 0)
            s += (4 - j);
        res = min(res, s);
    }
    cout << res << "\n";
}

signed main()
{
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}
M. Divide coins

构造题,前k个给1,后面n-k个全部翻转给2。

#include <bits/stdc++.h>
#define x first
#define y second
#define int long long

using namespace std;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const int N = 1000010, M = N * 2, mod = 1e9 + 7, P = 131;
int n, k;

void solve()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        if (i <= k)
            cout << "1";
        else
            cout << "4";
}

signed main()
{
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

剩下的后面补。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安特尼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值