Pre
Thanks guys giant strangers rent crisp rain careful guidance, even I can understand the konjac \ (F \) title.
A
Solution
Attendance success.
Code
#include<cstdio>
using namespace std;
int main(){int a;scanf ("%d", &a);printf("%d\n", 3 * a * a);return 0;}
B
Solution
Sign success
Code
#include<cstdio>
using namespace std;
int main(){
int a, b;
scanf ("%d%d", &a, &b);
int ans = a / (b * 2 + 1);
if (a > ans * (b * 2 + 1)) ans++;
printf ("%d\n", ans);
return 0;
}
C
Solution
It can be found in \ (n-1 \) answers are the same, to find out the maximum value and the second largest value on it.
Code
#include<bits/stdc++.h>
#define xx first
#define yy second
#define ll long long
using namespace std;
const int N = 200000 + 5;
int n;
pair<int, int> info[N];
int main () {
scanf ("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf ("%d", &info[i].xx);
info[i].yy = i;
}
sort (info + 1, info + n + 1);
for (int i = 1; i <= n; ++i) {
if (i == info[n].yy) {
printf ("%d\n", info[n - 1].xx);
}
else printf ("%d\n", info[n].xx);
}
return 0;
}
D
Solution
Determining a value of each forward from a rear position, the back of the first XOR and then again \ (a_i \) XOR up, it is the value of this position.
A harmonic series can know the time complexity \ (O (n \ logn) \) a.
Code
#include<bits/stdc++.h>
#define xx first
#define yy second
#define ll long long
using namespace std;
const int N = 200000 + 5;
int a[N], n, cnt;
int ans[N];
int main () {
scanf ("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf ("%d", &a[i]);
}
for (int i = n; i >= 1; --i) {
int tmp = 0;
for (int j = n / i; j >= 1; --j) {
tmp ^= ans[j * i];
}
ans[i] = tmp ^ a[i];
cnt += ans[i];
}
printf ("%d\n", cnt);
for (int i = 1; i <= n; ++i) {
if (!ans[i]) {continue;}
printf ("%d ", i);
}
return 0;
}
E
Solution
\ (Dilworth \) direct application, the number of rising sequences obtained it.
Code
#include<bits/stdc++.h>
#define xx first
#define yy second
#define ll long long
using namespace std;
const int N = 200000 + 5;
int a[N], n;
int stk[N], top;
int main () {
scanf ("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf ("%d", &a[i]);
}
stk[1] = 1;
top = 1;
for (int i = 2; i <= n; ++i) {
if (a[i] <= a[stk[top]]) {
stk[++top] = i;
}
else {
int l = 1, r = top;
while (l < r) {
int mid = (l + r) / 2;
if (a[stk[mid]] < a[i]) {
r = mid;
}
else {
l = mid + 1;
}
}
stk[l] = i;
}
}
printf ("%d\n", top);
return 0;
}
F
Solution
Consider using \ (f [i] [j ] [k] \) to indicate the front \ (I \) number, and wherein there are \ (J \) th is greater than \ (I \) , and at this time \ (oddness \) to \ (k \) the number of programs.
Because statistics is certainly there \ (j \) a greater than \ (i \) , in which case for each larger than \ (i \) , we only count \ (ij \) to \ (k \) contribution.
So \ (f [i] [j ] [k] \) can only \ (f [i + 1] [xxxx] [k + j] \) contribute, so we need to discuss different \ (xxxx \ ) contribution.
Suppose \ (p [i + 1] = i + 1 \) case \ (xxxx = j \) and the coefficient \ (1 \)
Suppose \ (P [I +. 1] \ Leq I +. 1 \ & P [X] = I +. 1 \ & X \ Leq I +. 1 \) , in this case \ (X \) have \ (J \) choices, \ (p [j + 1] \) have \ (J \) choices, the \ (. 1-XXXX J = \) , and the coefficient \ (j * j \)
Suppose \ (P [I + 1]> I + 1 \ & P [X] = I + 1 \ & X> I + 1 \) , in this case \ (X \) have \ (1 \) choices, \ ( p [i + 1] \) have \ (J \) choices, the \ (J + 1 = XXXX \) , and the coefficient \ (1 \) .
The remaining case is \ ((P [I +. 1] \ I + Leq. 1) \ XOR \ (P [X] = I +. 1 \ X & \ I + Leq. 1). 1 = \) , this time with a \ ( 2 * j \) choices, and \ (J = XXXX \) , can be transferred.
Code
#include <cstdio>
using namespace std;
const int N = 50 + 5, mod = 1000000007;
int f[N][N][N * N];
inline int add (int u, int v) { return u + v >= mod ? u + v - mod : u + v; }
inline int mns (int u, int v) { return u - v < 0 ? u - v + mod : u - v; }
inline int mul (int u, int v) { return 1LL * u * v % mod; }
int main () {
#ifdef chitongz
freopen ("x.in", "r", stdin);
#endif
int n, k;
scanf ("%d%d", &n, &k);
if (k % 2) return puts ("0"), 0;
f[1][1][0] = f[1][0][0] = 1;
for (int i = 1; i < n; ++i) {
for (int j = 0; j <= i; ++j) {
for (int k = 0; k <= i * i / 2; ++k) {
f[i + 1][j][k + j] = add (f[i + 1][j][k + j], mul (2 * j + 1, f[i][j][k]));
f[i + 1][j + 1][k + j] = add (f[i + 1][j + 1][k + j], f[i][j][k]);
if (j) f[i + 1][j - 1][k + j] = add (f[i + 1][j - 1][k + j], mul (j * j, f[i][j][k]));
}
}
}
printf ("%d\n", f[n][0][k / 2]);
return 0;
}
Conclusion
\ (F \) Yes, interesting.
In short pigeon took so long to fill the hole, I was too weak.