SDUST 2015双十一特别赛题解

1、脱单多久了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
//Chengrui1996
#include <stdio.h>
int a[] = {0, 316, 285, 257, 226, 196, 165, 135, 104, 73, 43, 12};
int main() {
int m, d, i;
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
while (~scanf("%d%d", &m, &d)) {
printf("%d\n", a[m] - d);
}
return 0;
}

2、该约哪一个:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Chengrui1996
#include <stdio.h>
int main() {
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
int n, i;
while (~scanf("%d", &n)) {
int x, y, v = 0x3f3f3f3f, ans = 0;
scanf("%d%d", &x, &y);
for (i = 1; i <= n; ++i) {
int a, b; scanf("%d%d", &a, &b);
int tmp = (x - a) * (x - a) + (y - b) * (y - b) + (x + y - a - b) * (x + y - a - b);
if (tmp < v) {
v = tmp;
ans = i;
}
}
printf("%d\n", ans);
}
return 0;
}

3、去吃哪家好:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Chengrui1996
#include <stdio.h>
#define inf 0x3f3f3f3f;
#define maxn 205
double ax[maxn], ay[maxn], bx[maxn], by[maxn];
int main() {
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
int n, m, i, j;
while (~scanf("%d%d", &n, &m)) {
double X, Y; scanf("%lf%lf", &X, &Y);
for (i = 1; i <= n; ++i) {
scanf("%lf%lf", &ax[i], &ay[i]);
}
for (i = 1; i <= m; ++i) {
scanf("%lf%lf", &bx[i], &by[i]);
}
int a = 0, b = 0;
double ans = inf;
for (i = 1; i <= n; ++i) {
double len = sqrt((ax[i] - X) * (ax[i] - X) + (ay[i] - Y) * (ay[i] - Y));
for (j = 1; j <= m; ++j) {
double cur = len + sqrt((ax[i] - bx[j]) * (ax[i] - bx[j]) + (ay[i] - by[j]) * (ay[i] - by[j]));
if (cur < ans) {
ans = cur;
a = i, b = j;
}
}
}
printf("%.4lf %d %d\n", ans, a, b);
}
return 0;
}

4、快抢电影票:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//Chengrui1996
#include <stdio.h>
#define inf 1 << 20
#define maxn 25
int a[maxn];
int main() {
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
int n, m;
while (~scanf("%d%d", &n, &m)) {
int ans = inf;
while (n--) {
int tmp = 0, i;
for (i = 1; i <= m; ++i) {
scanf("%d", &a[i]);
if (a[i] < 0) a[i] = inf;
tmp += a[i];
if (i >= 5) tmp -= a[i - 4];
if (i == m) tmp -= a[i - 3];
if (i >= 3 && tmp < ans) ans = tmp;
}
}
if (ans == inf) puts("Word sing how turn!");
else printf("%d\n", ans);
}
return 0;
}

5、大力出奇迹:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//Chengrui1996
#include <stdio.h>
#define maxn 55
long long c[maxn][maxn];
int main() {
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
c[0][0] = 1;
int i, j;
for (i = 1; i < maxn; ++i) {
c[i][0] = 1;
for (j = 1; j <= i; ++j) {
c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
}
}
int a, x, n, m;
while (~scanf("%d%d%d%d", &a, &x, &n, &m)) {
x /= a;
if (m == 0 || x == 0) {
puts("0.0000");
continue;
}
if (x > n - m) {
puts("1.0000");
continue;
}
printf("%.4lf\n", 1.0 - (double)c[n - m][x] / c[n][x]);
}
return 0;
}

本文迁移自我的 CSDN博客 ,格式可能有所偏差。