首页 >web前端 >html教程 >RCC 2014 Warmup (Div. 2)_html/css_WEB-ITnose

RCC 2014 Warmup (Div. 2)_html/css_WEB-ITnose

WBOY
WBOY原创
2016-06-24 12:05:581187浏览

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 <stdio.h>#include <string.h>#include <math.h>2 #define min(a,b) ((a)  <br> B:  <p></p>  <p></p>  <pre name="code" class="sycode">#include <stdio.h>#include <string.h>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   <br> C:  <p></p>  <p></p>  <pre name="code" class="sycode">#include <stdio.h>#include <string.h>int n, k;int main() {    scanf("%d%d", &n, &k);    if ((n - k)  n) b -= n;                printf("%d %d\n", a, b);            }        }    }    return 0;}</string.h></stdio.h>

D:

#include <stdio.h>#include <string.h>#include <algorithm>#define min(a,b) ((a)  <br> E:  <p></p>  <p></p>  <pre name="code" class="sycode">#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>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   <br>  <br>  <p></p>  <p><br> </p> </cstdlib></cmath></cstring></cstdio>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn