Codeforces Round #414 Div.2
Posted p0ny^v^
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #414 Div.2相关的知识,希望对你有一定的参考价值。
A 膜你
1 #include<cstdio> 2 #include<iostream> 3 using namespace std; 4 5 int main() { 6 int a, b, c, n, ans = 0; 7 scanf("%d %d %d", &a, &b, &c); 8 scanf("%d", &n); 9 for (int p, i = 0; i < n; ++i) { 10 scanf("%d", &p); 11 if (b < p and p < c) ++ans; 12 } 13 printf("%d\n", ans); 14 return 0; 15 }
B 二分高
1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 using namespace std; 5 double eps = 1e-10; 6 double ans = 0, up = 0, each, down; 7 int n, h0; 8 inline int check(double h) { 9 down = (ans + h) / h0; 10 double area = (up + down) * h * 0.5; 11 if (abs(area - each) <= eps) 12 return 0; 13 else if (area > each) return -1; 14 else return 1; 15 } 16 17 18 int main() { 19 scanf("%d %d", &n, &h0); 20 each = h0 * 0.5 / n; 21 for (int i = 1; i < n; ++i) { 22 double l = 0, r = h0, h = 0; 23 for (int j = 0; j < 300; ++j) { 24 double mid = (l + r) / 2; 25 int res = check(mid); 26 if (!res) {h = mid; break;} 27 if (res == 1) { 28 h = l = mid; 29 } else { 30 h = r = mid; 31 } 32 } 33 ans += h; up = down; 34 printf("%.12lf ", ans); 35 } 36 puts(""); 37 return 0; 38 }
CDE 蒟蒻不会
人生第二次涨rating 激动
以上是关于Codeforces Round #414 Div.2的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #705 (Div. 2)
Codeforces Round #774 (Div. 2)
Codeforces Round #808 (Div. 1)(A~C)
Codeforces Round #717 (Div. 2)