This commit is contained in:
1 parent
7c9cad7f97
commit
bcc4c73f9f
2 files changed
+165
No files matched your search
+119
@@ -0,0 +1,119 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
const int dat[][3] = {
|
||||||
|
{1, -1, 0}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {-1, -1, 2}, {-1, 0, 2},
|
||||||
|
{0, 0, 2}, {0, 1, 2}, {1, 1, 2}, {-2, -2, 3},
|
||||||
|
{-11, 7, 10}, {0, 0, 0}, {0, 0, 0}, {-1, 2, 2},
|
||||||
|
{0, 2, 2}, {1, 2, 2}, {-2, -1, 3}, {-2, 0, 3},
|
||||||
|
{-2, 1, 3}, {-14, -11, 16}, {0, 0, 0}, {0, 0, 0},
|
||||||
|
{2, 2, 2}, {-1, -1, 3}, {-1, 0, 3}, {0, 0, 3},
|
||||||
|
{0, 1, 3}, {1, 1, 3}, {0, 0, 0}, {0, 0, 0},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {-1, 2, 3}, {0, 2, 3},
|
||||||
|
{1, 2, 3}, {-3, 0, 4}, {-3, 1, 4}, {0, 0, 0},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {2, 2, 3},
|
||||||
|
{-7, -5, 8}, {-3, 2, 4}, {-2, 3, 3}, {-8, 6, 7},
|
||||||
|
{-2, -2, 4}, {0, 0, 0}, {0, 0, 0}, {-796, 602, 659},
|
||||||
|
{0, 0, 0}, {-1, 3, 3}, {0, 3, 3}, {1, 3, 3},
|
||||||
|
{-2, 0, 4}, {-2, 1, 4}, {0, 0, 0}, {0, 0, 0},
|
||||||
|
{-4, -1, 5}, {-4, 0, 5}, {2, 3, 3}, {-1, 0, 4},
|
||||||
|
{0, 0, 4}, {0, 1, 4}, {1, 1, 4}, {0, 0, 0},
|
||||||
|
{0, 0, 0}, {-4, 2, 5}, {-21, 11, 20}, {-1, 2, 4},
|
||||||
|
{0, 2, 4}, {1, 2, 4}, {0, 0, 0}, {0, 0, 0},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {-55, 26, 53}, {-33, -19, 35},
|
||||||
|
{2, 2, 4}, {3, 3, 3}, {-11, -11, 14}, {-2, 3, 4},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {-4126, -1972, 4271},
|
||||||
|
{-4, 3, 5}, {-7, 6, 6}, {-1, 3, 4}, {0, 3, 4},
|
||||||
|
{1, 3, 4}, {-5, -5, 7}, {0, 0, 0}, {0, 0, 0},
|
||||||
|
{-22, 14, 20}, {-3, -1, 5}, {-3, 0, 5}, {2, 3, 4},
|
||||||
|
{-6, -3, 7}, {-3, 4, 4}, {-239, 118, 229}, {0, 0, 0},
|
||||||
|
{0, 0, 0}, {-7, -4, 8}, {-3, 2, 5}, {-48, -28, 51},
|
||||||
|
{-1165, -948, 1345}, {-2, -2, 5}, {0, 0, 0}, {-881, -296, 892},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {-10, -6, 11},
|
||||||
|
{-2, -1, 5}, {-2, 0, 5}, {3, 3, 4}, {-6, -2, 7},
|
||||||
|
{-2, 4, 4}, {0, 0, 0}, {0, 0, 0}, {-1, -1, 5},
|
||||||
|
{-1, 0, 5}, {0, 0, 5}, {0, 1, 5}, {1, 1, 5},
|
||||||
|
{0, 4, 4}, {1, 4, 4}, {0, 0, 0}, {0, 0, 0},
|
||||||
|
{-1, 2, 5}, {0, 2, 5}, {1, 2, 5}, {-6, 2, 7},
|
||||||
|
{2, 4, 4}, {-11, -9, 13}, {-86, -77, 103}, {0, 0, 0},
|
||||||
|
{0, 0, 0}, {2, 2, 5}, {-7, -3, 8}, {0, 0, 0},
|
||||||
|
{-2, 3, 5}, {-8, -7, 10}, {-9, -5, 10}, {-56, -50, 67},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {-367, 260, 317}, {-1, 3, 5},
|
||||||
|
{0, 3, 5}, {1, 3, 5}, {-5, -4, 7}, {3, 4, 4},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {-130, 80, 119},
|
||||||
|
{2, 3, 5}, {-7, -2, 8}, {-3, 4, 5}, {-26, -21, 30},
|
||||||
|
{-47, -45, 58}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||||
|
{-7, -1, 8}, {-7, 0, 8}, {-7, 1, 8}, {-6, -5, 8},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {-8, 7, 7}, {0, 0, 0},
|
||||||
|
{0, 0, 0}, {-7, 2, 8}, {-13, -10, 15}, {3, 3, 5},
|
||||||
|
{0, 0, 0}, {-2, 4, 5}, {-14, 9, 13}, {-17, 10, 16},
|
||||||
|
{0, 0, 0}, {0, 0, 0}, {-4, 5, 5}, {-58, 27, 56},
|
||||||
|
{-1, 4, 5}, {0, 4, 5}, {1, 4, 5}, {-5, -3, 7},
|
||||||
|
{4, 4, 4}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
|
||||||
|
{-7, 3, 8}, {2, 4, 5}, {-48, -19, 49}, {-24, 15, 22},
|
||||||
|
{-2, -2, 6},
|
||||||
|
};
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
scanf("%d", &t);
|
||||||
|
while (t--) {
|
||||||
|
int x;
|
||||||
|
scanf("%d", &x);
|
||||||
|
int a = dat[x][0], b = dat[x][1], c = dat[x][2];
|
||||||
|
if (a == 0 && b == 0 && c == 0) {
|
||||||
|
printf("impossible\n");
|
||||||
|
} else {
|
||||||
|
printf("%d %d %d\n", a, b, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
struct ans {
|
||||||
|
int a, b, c;
|
||||||
|
bool flag;
|
||||||
|
} ans[205];
|
||||||
|
int remain = 201;
|
||||||
|
long long cube[10005];
|
||||||
|
int main() {
|
||||||
|
for (int i = -5000; i <= 5000; i++)
|
||||||
|
cube[i + 5000] = 1ll * i * i * i;
|
||||||
|
// a <= b <= c
|
||||||
|
for (int a = -5000; a <= 4 && remain; a++) {
|
||||||
|
int bmax = min(5000, (int)cbrt((200 - cube[a + 5000]) / 2.0) + 1);
|
||||||
|
for (int b = a; b <= bmax && remain; b++) {
|
||||||
|
// - a^3 - b^3 <= c <= 200 - a^3 - b^3
|
||||||
|
int cmax = cbrt(200 - cube[a + 5000] - cube[b + 5000]) + 1,
|
||||||
|
cmin = cbrt(-cube[a + 5000] - cube[b + 5000]) - 1;
|
||||||
|
int L = max(max(cmin, -5000), b);
|
||||||
|
int R = min(cmax, 5000);
|
||||||
|
if (L > R) {
|
||||||
|
if (b > min(cmax, 5000) || cmax < -5000)
|
||||||
|
break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int c = max(max(cmin, -5000), b); c <= min(cmax, 5000); c++) {
|
||||||
|
int now = cube[a + 5000] + cube[b + 5000] + cube[c + 5000];
|
||||||
|
if (0 <= now && now <= 200) {
|
||||||
|
if (!ans[now].flag)
|
||||||
|
ans[now] = {a, b, c, 1}, remain--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int t;
|
||||||
|
scanf("%d", &t);
|
||||||
|
while (t--) {
|
||||||
|
int x;
|
||||||
|
scanf("%d", &x);
|
||||||
|
if (ans[x].flag) {
|
||||||
|
printf("%d %d %d\n", ans[x].a, ans[x].b, ans[x].c);
|
||||||
|
} else {
|
||||||
|
printf("impossible\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# P17736 [ICPC 2019 Xuzhou R] The Answer to the Ultimate Question of Life, The Universe, and Everything.
|
||||||
|
|
||||||
|
## 题目描述
|
||||||
|
|
||||||
|
数十年来,科学家们一直想知道从 0 到 100 的每个数字是否都可以表示为三个立方数之和,其中立方数是指同一个数自乘三次。
|
||||||
|
|
||||||
|
42 是最后一个没有已知解的数字——直到现在。
|
||||||
|
|
||||||
|
其解为 $(-80538738812075974)^3 + 80435758145817515^3 + 12602123297335631^3 = 42$。
|
||||||
|
|
||||||
|
现在,Yen-Jen 怀疑是否还有其他解存在。但是,这些解并不容易找到。Yen-Jen 想要先找出一些**简单解**。也就是说,对于方程 $a^3 + b^3 + c^3 = x$,Yen-Jen 希望为 $[0, 200]$ 内的每个整数 $x$ 找出至少一组解,其中 $|a|, |b|, |c| \le 5000$。
|
||||||
|
|
||||||
|
由于 Yen-Jen 仍在忙着准备某个(也许是这道题的?)测试数据,请你帮他为每个 $x$ 找出至少一组解,或者告诉他当 $|a|, |b|, |c| \le 5000$ 时解不存在。
|
||||||
|
|
||||||
|
## 输入格式
|
||||||
|
|
||||||
|
第一行包含一个整数 $T$,表示需要检查的 $x$ 的个数。
|
||||||
|
接下来的 $T$ 行,每行包含一个整数 $x$。
|
||||||
|
|
||||||
|
- $1 \le T \le 10$
|
||||||
|
- $0 \le x \le 200$
|
||||||
|
|
||||||
|
## 输出格式
|
||||||
|
|
||||||
|
对于每组测试数据,输出一行三个由空格分隔的整数 $a, b, c$,满足 $a^3 + b^3 + c^3 = x$ 且 $|a|, |b|, |c| \le 5000$。如果解不存在,输出 `impossible`。
|
||||||
|
|
||||||
|
## 输入输出样例 #1
|
||||||
|
|
||||||
|
### 输入 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
2
|
||||||
|
1
|
||||||
|
2
|
||||||
|
```
|
||||||
|
|
||||||
|
### 输出 #1
|
||||||
|
|
||||||
|
```
|
||||||
|
1 1 -1
|
||||||
|
1 1 0
|
||||||
|
```
|
||||||
|
|
||||||
|
## 说明/提示
|
||||||
|
|
||||||
|
翻译由 DeepSeek V4 Pro 完成
|
||||||
Reference in new issue
Block a user