Codeforces Round #532 (Div. 2) Solution

A. Roman and Browser

签到.

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 int n, k, a[110];
 5 
 6 int get(int b)
 7 {
 8     int vis[110];
 9     memset(vis, 0, sizeof vis);
10     int c = b; 
11     while (c <= n)
12     {
13         vis[c] = 1;
14         c += k;
15     }
16     c = b - k;
17     while (c >= 1)
18     {
19         vis[c] = 1;
20         c -= k;
21     }
22     int l = 0, r = 0;
23     for (int i = 1; i <= n; ++i) if (!vis[i])
24     {
25         if (a[i] == 1) ++l;
26         else ++r;
27     }
28     return abs(l - r);
29 }
30 
31 int main()
32 {
33     while (scanf("%d%d", &n, &k) != EOF)
34     {
35         for (int i = 1; i <= n; ++i) scanf("%d", a + i);
36         int res = 0;
37         for (int i = 1; i <= n; ++i) res = max(res, get(i));
38         printf("%d\n", res);
39     }
40     return 0;
41 }
View Code


B. Build a Contest

签到.

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 #define N 100010
 5 int n, m, a[N];
 6 int cnt[N]; 
 7 
 8 int main()
 9 {
10     while (scanf("%d%d", &n, &m) != EOF)
11     {
12         for (int i = 1; i <= m; ++i) scanf("%d", a + i);
13         int need = n;
14         memset(cnt, 0, sizeof cnt);
15         for (int i = 1; i <= m; ++i)
16         {
17             if (cnt[a[i]] == 0)
18                 --need;
19             ++cnt[a[i]];
20             if (need) putchar('0');
21             else
22             {
23                 putchar('1');
24                 for (int j = 1; j <= n; ++j) 
25                 {
26                     --cnt[j];
27                     if (!cnt[j])
28                         ++need;
29                 }
30             }
31         }
32         puts("");
33     }
34     return 0;
35 }
View Code

C. NN and the Optical Illusion

签到.

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 const double eps = 1e-8;
 5 const double PI = acos(-1.0);
 6 
 7 int main()
 8 {
 9     int n; double r;
10     while (scanf("%d%lf", &n, &r) != EOF)
11     {
12         double ang1 = 2.0 * PI / n;
13         double ang2 = (PI - ang1) / 2;
14         double R = (r * sin(ang1) * 1.0) / (2 * sin(ang2) - sin(ang1));
15         printf("%.10f\n", R);
16     }
17     return 0;
18 }
View Code

E. Andrew and Taxi

Unsolved.

题意:

给出一张有向图,求改变一些边使得它没有环

改变一条边的花费是它的边权,要使得最大花费最小

输出最大花费和需要改变的边数

再输出相应的边

猜你喜欢

转载自www.cnblogs.com/Dup4/p/10265069.html