bzoj 1087 1193 1218 2462
parent
9e07980f2f
commit
410ce1de74
@ -0,0 +1,31 @@
|
||||
#include <cstdio>
|
||||
long long fun[10][82] = {
|
||||
{},
|
||||
{0, 1},
|
||||
{0, 4},
|
||||
{0, 9, 16, 8, 1},
|
||||
{0, 16, 78, 140, 79},
|
||||
{0, 25, 228, 964, 1987, 1974, 978, 242, 27, 1},
|
||||
{0, 36, 520, 3920, 16834, 42368, 62266, 51504, 21792, 3600},
|
||||
{0, 49, 1020, 11860, 85275, 397014, 1220298, 2484382, 3324193, 2882737, 1601292, 569818, 129657, 18389, 1520, 64, 1},
|
||||
{0, 64, 1806, 29708, 317471, 2326320, 12033330, 44601420, 119138166, 229095676, 314949564, 305560392, 204883338, 91802548, 25952226, 4142000, 281571},
|
||||
{0, 81,
|
||||
2968, 65240,
|
||||
962089, 10087628,
|
||||
77784658, 450193818,
|
||||
1979541332, 6655170642,
|
||||
17143061738, 33787564116,
|
||||
50734210126, 57647295377,
|
||||
49138545860, 31122500764,
|
||||
14518795348, 4959383037,
|
||||
1237072414, 224463798,
|
||||
29275410, 2673322,
|
||||
163088, 6150,
|
||||
125, 1} };
|
||||
int main()
|
||||
{
|
||||
int n, k;
|
||||
scanf("%d %d", &n, &k);
|
||||
printf("%lld", fun[n][k]);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
inline int abs(int x) { return x > 0 ? x : -x; }
|
||||
inline void swap(int &x, int &y) { int t = x; x = y; y = t; }
|
||||
const int dx[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
|
||||
const int dy[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
|
||||
int que[1 << 20], head, tail, dis[(1 << 14) - 1];
|
||||
#define zip(x, y) ((x << 7) + y)
|
||||
#define unzip(x, y, val) (x = val >> 7, y = val & 127)
|
||||
int main()
|
||||
{
|
||||
int x, y, xp, yp, xs, ys;
|
||||
scanf("%d%d%d%d", &xp, &yp, &xs, &ys);
|
||||
x = abs(xs - xp), y = abs(ys - yp);
|
||||
int ans = 0;
|
||||
while (x + y >= 50)
|
||||
{
|
||||
if (x < y) swap(x, y);
|
||||
if (x - 4 >= y << 1) x -= 4;
|
||||
else x -= 4, y -= 2;
|
||||
ans += 2;
|
||||
}
|
||||
memset(dis, -1, sizeof(dis));
|
||||
int i = x, j = y;
|
||||
dis[que[tail++] = zip(i, j)] = 0;
|
||||
while (head < tail)
|
||||
{
|
||||
unzip(i, j, que[head]);
|
||||
head++;
|
||||
for (int k = 0; k < 8; k++)
|
||||
if (dis[zip(i + dx[k], j + dy[k])] == -1)
|
||||
dis[que[tail++] = zip(i + dx[k], j + dy[k])] = dis[zip(i, j)] + 1;
|
||||
}
|
||||
printf("%d", dis[0] + ans);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
#include <cstdio>
|
||||
#include <cctype>
|
||||
inline int max(int a, int b) { return a > b ? a : b; }
|
||||
inline void readInt(int &x)
|
||||
{
|
||||
int ch = x = 0;
|
||||
while (!isdigit(ch = getchar()));
|
||||
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
|
||||
}
|
||||
int a[5010][5010];
|
||||
int main()
|
||||
{
|
||||
int n, r;
|
||||
readInt(n), readInt(r);
|
||||
for (int i = 0, x, y, z; i < n; i++)
|
||||
{
|
||||
readInt(x), readInt(y), readInt(z);
|
||||
a[x + 1][y + 1] += z;
|
||||
}
|
||||
for (int i = 1; i < 5010; i++)
|
||||
for (int j = 1; j < 5010; j++)
|
||||
a[i][j] += a[i][j - 1];
|
||||
for (int i = 1; i < 5010; i++)
|
||||
for (int j = 1; j < 5010; j++)
|
||||
a[i][j] += a[i - 1][j];
|
||||
int ans = 0;
|
||||
for (int i = r; i < 5010; i++)
|
||||
for (int j = r; j < 5010; j++)
|
||||
ans = max(ans, a[i][j] - a[i][j - r] - a[i - r][j] + a[i - r][j - r]);
|
||||
printf("%d", ans);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
#include <cstdio>
|
||||
int main()
|
||||
{
|
||||
for(int i = 0; i < 10; i++)
|
||||
puts("1");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue