Part #1 水题
幂次划分
千年一遇的大水题!直接把这个序列丢进 oeis 里,很快啊,得到了递推式:
套递推式即可。
出题人保证下次不会再出 oeis 题了 TT。
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, mod, a[N];
int main () {
scanf ("%d%d", &n, &mod);
a[1] = 1;
puts ("1");
for (int i = 2; i <= n; i++) {
if (i & 1) {
a[i] = a[i - 1];
} else {
a[i] = (1ll * a[i / 2] + a[i - 1]) % mod;
}
printf ("%d\n", a[i]);
}
return 0;
}卡牌翻转
唯一剩下一道有 std 的,放一下 std 吧。
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int T, n, cnt, a[N], p[N], c[N], sta[N];
bool b[N];
char s[N];
int x[N * 3], y[N * 3];
void strategy (int s, int t) {
x[++cnt] = s;
y[cnt] = t;
c[sta[s]] = 1 - c[sta[s]];
c[sta[t]] = 1 - c[sta[t]];
swap (p[sta[s]], p[sta[t]]);
swap (sta[s], sta[t]);
}
int main () {
scanf ("%d", &T);
while (T --> 0) {
scanf ("%d%*d", &n);
for (int i = 1; i <= n; i++) {
scanf ("%d", &a[i]);
}
scanf ("%s", s + 1);
cnt = 0;
for (int i = 1; i <= n; i++) {
b[i] = s[i] - '0';
cnt += b[i];
p[i] = sta[i] = i;
c[i] = 0;
}
if (n == 2) {
if (a[1] == 1 && a[2] == 2 && b[1] == 0 && b[2] == 0) {
puts ("0");
} else if (a[1] == 2 && a[2] == 1 && b[1] == 1 && b[2] == 1) {
puts ("1\n1 2");
} else {
puts ("-1");
}
continue;
}
if (cnt & 1) {
puts ("-1");
continue;
}
cnt = 0;
for (int i = 1; i < n - 1; i++) {
if (a[i] == sta[i]) {
if (b[i] != c[a[i]]) {
strategy (i, i + 1);
strategy (i + 1, i + 2);
strategy (i, i + 2);
}
continue;
}
if (b[i] != c[a[i]]) {
strategy (i, p[a[i]]);
} else {
strategy (p[a[i]], p[a[i]] == i + 1? p[a[i]] + 1: i + 1);
strategy (i, p[a[i]]);
}
}
if (b[n] != c[a[n]]) {
strategy (n - 1, n);
}
if (a[n] != sta[n]) {
strategy (1, n - 1);
strategy (1, n);
strategy (1, n - 1);
}
printf ("%d\n", cnt);
for (int i = 1; i <= cnt; i++) {
printf ("%d %d\n", x[i], y[i]);
}
}
return 0;
}称重
来自一道 MO 题。暂不公开。
平方数合并
暂不公开。
【暂不公开】
排序游戏
暂不公开。
对数基
暂不公开。
Part #2 板题
比赛
暂不公开。
一组数列
暂不公开。
划分
暂不公开。
经典游戏
暂不公开。
试题
暂不公开。
树的直径
暂不公开。