Codeforces Round #512 (Div. 2)
程序员文章站
2022-03-02 23:23:59
...
A
水题,数据中有1就是HARD,没有就是EASY
#include <cstdio>
int n;
bool ok = false;
int main()
{
scanf("%d", &n);
while (n--) {
int a;
scanf("%d", &a);
if (a == 1) ok = true;
}
ok ? puts("HARD") : puts("EASY");
return 0;
}
B
线性规划
#include <cstdio>
int n, d, t;
int main()
{
scanf("%d %d %d", &n, &d, &t);
while (t--) {
int x, y;
scanf("%d %d", &x, &y);
if (y >= x - d && y >= d - x && y <= x + d && y <= -x + 2 * n - d)
puts("YES");
else puts("NO");
}
return 0;
}
C
数据范围很小,直接暴力枚举分成的每个部分中各项的和,然后判断一下可不可以这么分即可
#include <cstdio>
#include <iostream>
const int MAXN = 100 + 2;
int n, sum;
char s[MAXN];
bool is_ok(int num) {
int cnt = 0, sum = 0;
for (int i = 1; i <= n; i++) {
sum += s[i] - '0';
if (sum == num) {
cnt++;
sum = 0;
}
}
if (sum != 0) return false;
if (cnt >= 2) return true;
return false;
}
int main()
{
scanf("%d", &n);
scanf("%s", s + 1);
for (int i = 1; i <= n; i++)
sum += s[i] - '0';
int flag = true;
for (int i = 1; i <= n; i++) {
if (s[i] != '0') flag = false;
}
if (flag) {
puts("YES");
return 0;
}
for (int i = 1; i <= sum; i++)
if (is_ok(i)) {
puts("YES");
return 0;
}
puts("NO");
return 0;
}
D
以(0, 0),(x, 0),(0, y)为三点的三角形是可以表示出最大面积的(x <= n, y <= m),所以只需要保证x和y都为整数且满足题意即可。
#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
int main()
{
scanf("%lld %lld %lld", &n, &m, &k);
if (2 * n * m % k != 0) {
puts("NO");
return 0;
}
puts("YES");
if (__gcd(2 * n, k) == 1) {
printf("0 0\n");
printf("%lld 0\n", n);
printf("0 %lld\n", 2 * m / k);
}
else {
printf("0 0\n");
printf("%lld 0\n", 2 * n / __gcd(2 * n, k));
printf("0 %lld\n", m / (k / __gcd(2 * n, k)));
}
return 0;
}
推荐阅读
-
Codeforces Round #595 (Div. 3)D1D2 贪心 STL
-
Codeforces Round #655 (Div. 2) A. Omkar and Completion
-
Codeforces Round #656 (Div. 3)D. a-Good String(递归+dfs)
-
Codeforces Round #487 (Div. 2)
-
CodeForces 1324 - Codeforces Round #627 (Div. 3)
-
Codeforces Round #649 (Div. 2)-B. Most socially-distanced subsequence(思维)
-
Codeforces Round #649 (Div. 2) C-Ehab and Prefix MEXs
-
Educational Codeforces Round 71 (Rated for Div. 2)E. XOR Guessing
-
Codeforces Round #659 (Div. 2) A. Common Prefixes(字符串,思维)
-
Codeforces Round #610 (Div. 2)