A-Apples and Ideas
签到题。相互交换苹果和想法,苹果互换,想法相加。
#include <cstdio>
int main()
{
int t;
scanf("%d", &t);
while (t--) {
int a, b, c, d;
scanf("%d%d%d%d", &a, &b, &c, &d);
printf("%d %d\n", c, b+d);
printf("%d %d\n", a, b+d);
}
return 0;
}
C-Defuse the Bomb
一个炸弹上有一个显示器和四个按钮。显示器上显示不同的数代表不同的阶段。根据不同的阶段按下不同的按钮即可拆除炸弹。
按题目要求进行操作即可,输入每阶段四个按钮的值,留下最终按下的按钮,最后遍历一遍即可。
代码较长需仔细。
#include <cstdio>
int main()
{
int t;
int b[6][5];
scanf("%d", &t);
for (int i = 0; i < t; i++) {
for (int j = 1; j <= 5; j++) {
int d;
scanf("%d", &d);
for (int k = 1; k <= 4; k++)
scanf("%d", &b[j][k]);
//stage 1
if (j == 1) {
if (d == 1) {
for (int k = 1; k <= 4; k++) {
if (k == 2)
continue;
b[j][k] = 0;
}
}
else if (d == 2) {
for (int k = 1; k <= 4; k++) {
if (k == 2)
continue;
b[j][k] = 0;
}
}
else if (d == 3) {
for (int k = 1; k <= 4; k++) {
if (k == 3)
continue;
b[j][k] = 0;
}
}
else {
for (int k = 1; k <= 4; k++) {
if (k == 4)
continue;
b[j][k] = 0;
}
}
}
//stage 2
else if (j == 2) {
if (d == 1) {
for (int k = 1; k <= 4; k++) {
if (b[j][k] == 4)
continue;
b[j][k] = 0;
}
}
else if (d == 2) {
for (int k = 1; k <= 4; k++) {
if (b[1][k] != 0)
continue;
b[j][k] = 0;
}
}
else if (d == 3) {
for (int k = 1; k <= 4; k++) {
if (k == 1)
continue;
b[j][k] = 0;
}
}
else {
for (int k = 1; k <= 4; k++) {
if (b[1][k] != 0)
continue;
b[j][k] = 0;
}
}
}
//stage 3
else if (j == 3) {
if (d == 1) {
for (int k = 1; k <= 4; k++