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 longusing 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 longusing 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 longusing 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";elsecout << "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;
}
剩下的后面补。