RCC 2014 Warmup (Div. 2)_html/css_WEB-ITnose
程序员文章站
2022-05-17 08:21:37
...
A题:看是全用c好还是全用d好还是都用的问题最少,注意 n * m
B题:题意坑死了,就开一个vis数组记录每个人前面的提交数,如果矛盾就false
C题:构造,只要判断n - k 是否
D题:状压DP,按k排序,然后dp数组只要记录完成集合,利用滚动数组优化空间,然后每次加上k * d去取最小值即可
E题:构造问题,不过用随机算法貌似更简便。构造出来的矩阵应该是
a a a a a b
a a a a a b
a a a a a b
c c c c c d
这样的,然后只要去随机a, b, c, d判断每行每列和是不是完全平方数即可
代码:
A:
#include#include #include 2 #define min(a,b) ((a)
B:#include#include const int N = 100005;int n, vis[N];struct Solu { int x, k;} s[N];bool judge() { memset(vis, 0, sizeof(vis)); for (int i = 0; i vis[k]) return false; } return true;}int main() { scanf("%d", &n); for (int i = 0; i
C:#include#include int n, k;int main() { scanf("%d%d", &n, &k); if ((n - k) n) b -= n; printf("%d %d\n", a, b); } } } return 0;}
D:#include#include #include #define min(a,b) ((a)
E:#include#include #include #include int n, m;bool check(int num) { int m = (int)sqrt(num); return m * m == num;}int main() { scanf("%d%d", &n, &m); int a, b, c, d, i, j; while (1) { a = rand() % 100 + 1; b = rand() % 100 + 1; c = rand() % 100 + 1; d = rand() % 100 + 1; if (check((m - 1) * a * a + b * b) && check((m - 1) * c * c + d * d) && check((n - 1) * a * a + c * c) && check((n - 1) * b * b + d * d)) break; } for (i = 0; i
推荐阅读
-
Codeforces Round #156 (Div. 2)-A. Greg's Workout_html/css_WEB-ITnose
-
Codeforces Round #107 (Div. 2)-A. Soft Drinking_html/css_WEB-ITnose
-
Codeforces Round #191 (Div. 2)-A. Flipping Game_html/css_WEB-ITnose
-
Codeforces Round #279 (Div. 2)_html/css_WEB-ITnose
-
Codeforces Round #278 (Div. 2)B?? Candy Boxes_html/css_WEB-ITnose
-
Codeforces Round #277.5 (Div. 2) 解题报告_html/css_WEB-ITnose
-
Codeforces Beta Round #75 (Div. 2)-A. Chips_html/css_WEB-ITnose
-
Codeforces Round #149 (Div. 2)_html/css_WEB-ITnose
-
Codeforces Round #277.5 (Div. 2)(C题)_html/css_WEB-ITnose
-
Codeforces Round #144 (Div. 2)-A. Perfect Permutation_html/css_WEB-ITnose