第二十周 1.10-1.16

考完来补了。讲道理的话考试周还属于学期里阿。

1.10-1.13

中间打了场CF edu。

1.14

鸡场补题boy。

CF 616 E Sum of Remainders

式子变成mn-sigma(n/i*i)就是n^0.5的搞。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 using namespace std;
 5 typedef long long LL;
 6 const LL mod = 1e9 + 7;
 7 
 8 int main(void)
 9 {
10     LL n, m, tmp = 0LL, rev = 500000004LL;
11     scanf("%I64d%I64d", &n, &m);
12     LL p = min(m, n);
13     for(LL i = 1; i <= p; i++)
14     {
15         LL r = min(p, n / ( n / i ) );
16         tmp = ( tmp + (i + r) % mod * ( (r - i + 1LL) % mod ) % mod * rev % mod * (n / i) % mod ) % mod;
17         i = r;
18     }
19     printf("%I64d
", ( m % mod * ( n % mod ) % mod - tmp + mod ) % mod );
20     return 0;
21 }
Aguin

1.15

打个CF。

CF 614 C Peter and Snow Blower

讨厌计几。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cmath>
 4 #include <algorithm>
 5 using namespace std;
 6 typedef long long LL;
 7 const double pi = acos(-1);
 8 const double INF = 1e18;
 9 const int maxn = 1e5 + 10;
10 LL x, y, xx[maxn], yy[maxn];
11 
12 double P2S(int i, int j)
13 {
14     LL vx[4], vy[4];
15     vx[1] = xx[j] - xx[i];
16     vy[1] = yy[j] - yy[i];
17     vx[2] = x - xx[i];
18     vy[2] = y - yy[i];
19     vx[3] = x - xx[j];
20     vy[3] = y - yy[j];
21     if( vx[1] * vx[2] + vy[1] * vy[2] < 0 ) return vx[2] * vx[2] + vy[2] * vy[2];
22     if( vx[1] * vx[3] + vy[1] * vy[3] > 0 ) return vx[3] * vx[3] + vy[3] * vy[3];
23     return 1.0 * ( vx[1] * vy[2] - vx[2] * vy[1] ) * ( vx[1] * vy[2] - vx[2] * vy[1] ) / ( vx[1] * vx[1] + vy[1] * vy[1] );
24 }
25 
26 int main(void)
27 {
28     int n;
29     double Min = INF, Max = -1;
30     scanf("%d%I64d%I64d", &n, &x, &y);
31     for(int i = 0; i < n; i++)
32     {
33         scanf("%I64d%I64d", xx + i, yy + i);
34         double d = (xx[i] - x) * (xx[i] - x) + (yy[i] - y) * (yy[i] - y);
35         Max = max(Max, d);
36     }
37     for(int i = 0, j = n - 1; i < n; j = i++) Min = min(Min, P2S(i, j));
38     printf("%.12lf
",pi * (Max - Min));
39     return 0;
40 }
Aguin

1.16

CF 614 D Skills

尺取。初始化跪RE了QAQ

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 using namespace std;
 5 typedef long long LL;
 6 const int maxn = 1e5 + 10;
 7 LL cpy[maxn], sum[maxn];
 8 struct node{int id; LL a;} ori[maxn];
 9 bool cmp(node A, node B){return A.a < B.a;}
10 
11 int main(void)
12 {
13     int n, p1 = 0, ap1 = 0, ap2 = n + 1;
14     LL cf, cm, A, m, ans = 0LL, tmp, Min;
15     scanf("%d%I64d%I64d%I64d%I64d", &n, &A, &cf, &cm, &m);
16     for(int i = 1; i <= n; i++)
17     {
18         scanf("%I64d", &ori[i].a);
19         ori[i].id = i;
20         cpy[i] = ori[i].a;
21     }
22     sort(ori + 1, ori + 1 + n, cmp);
23     for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + ori[i].a;
24     for(int p2 = 2; p2 <= n + 1; p2++)
25     {
26         LL c = A * (n - p2 + 1) - sum[n] + sum[p2-1];
27         if(c > m) continue;
28         tmp = cf * (n - p2 + 1);
29         LL l = m - c;
30         while( p1 < p2 - 1 && ori[p1+1].a * (p1 + 1) - sum[p1+1] <= l ) p1++;
31         l -= ori[p1].a * p1 - sum[p1];
32         if( ori[p1].a + l / p1 < A) tmp += (ori[p1].a + l / p1) * cm;
33         else tmp += A * cm + cf * p1;
34         if(tmp > ans) ans = tmp, ap1 = p1, ap2 = p2, Min = min(A, ( ori[p1].a + l / p1 ));
35     }
36     for(int i = 1; i <= ap1; i++) cpy[ori[i].id] = Min;
37     for(int i = ap2; i <= n; i++) cpy[ori[i].id] = A;
38     printf("%I64d
", ans);
39     for(int i = 1; i <= n; i++) printf("%I64d ", cpy[i]);
40     puts("");
41     return 0;
42 }
Aguin
原文地址:https://www.cnblogs.com/Aguin/p/5127355.html