1. 俄罗斯方块
#include <iostream>
using namespace std;
const int MAXN = 1005;
int cnt[MAXN]; //第i列的方块个数
int n, m, c, score;
bool check(int n, int c) {
bool flag = true;
for (int i = 1; i <= n; i++) {
if (!cnt[i]) {
flag = false;
break;
}
}
return flag;
}
int main() {
cin >> n >> m;
while (m--) {
cin >> c;
cnt[c]++;
if (check(n, c)) {
score++;
for (int i = 1; i <= n; i++) cnt[i]--;
}
}
cout << score << '\n';
return 0;
}
2. 瞌睡
3. 丰收
5. 表达式求值
#include <cstdio>
#include <iostream>
using namespace std;
int maxV, a, b, c;
int main() {
scanf("%d%d%d", &a, &b, &c);
if (a == 1) {
if (c == 1) maxV = a + b + c;
else maxV = (a + b)*c;
}
else {
if (c == 1) maxV = a * (b + c);
else {
if (b == 1) {
if (a > c) maxV = a * (b + c);
else maxV = (a + b)*c;
}
else maxV = a * b*c;
}
}
printf("%d\n", maxV);
return 0;
}
参照:
【1】https://www.nowcoder.com/profile/9664604/test/18246477/224353#summary