Warning: session_start(): open(/tmp/sess_bfc2851337b9301eba8fd7de0014e863, O_RDWR) failed: No space left on device (28) in /data/wiki/inc/init.php on line 239

Warning: session_start(): Failed to read session data: files (path: ) in /data/wiki/inc/init.php on line 239

Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/auth.php on line 430

Warning: mkdir(): No space left on device in /data/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Cache.php on line 19
Temporary files directory "/data/wiki/data/tmp/dwpdf/860/" is not writable
Writing /data/wiki/data/cache/d/de2edb2fcb553ea79b79c722a4e13dbc.captchaip failed

Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/actions.php on line 38

Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/lib/tpl/dokuwiki/main.php on line 12
2020-2021:teams:too_low:cfedu92hj [CVBB ACM Team]

用户工具

站点工具


2020-2021:teams:too_low:cfedu92hj

A.LCM Problem

https://codeforces.com/contest/1389/problem/A

题意: 找到[l, r]范围内的两个数x < y使得其最小公倍数也在[l, r]范围内。

设x = p * gcd(x, y) ,y = q * gcd(x, y) ,pq互质。lcm(x, y) = pq*gcd(x, y)。 x确定时y = 2x 时lcm(x, y) = y取到最小值

x = l时存在解有= 2*l。判断r是否小于2*l即可。

点击以显示 ⇲

点击以隐藏 ⇱

#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
 
 
 
int main() {
    int t = 0;
    cin >> t;
    while (t--) {
        LL l, r;
        cin>>l>>r;
        if(r < 2 * l)cout<<-1<<' '<<-1<<endl;
        else cout<<l<<' '<<2*l<<endl;
    }
 

B.Array Walk

题意:给定一个数组,起始位置在下标1处,可以选择向左走与向右走,不可重复向左走,向左走总次数不得超过p,总共走k次,求经过路径上数组元素值和的最大值。

贪心。对于1-x范围内的路径,三种情况可能为最优值: 找到相邻两项和的最大值,在这相邻两项间重复走min(p, k-p/2)次。 找到相邻两项和的最大值,在这相邻两项间重复走min(p, k-p/2)次, 再在结尾向左走1次。 1→x→x-1

点击以显示 ⇲

点击以隐藏 ⇱

 
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
 
LL a[100005];
LL maxA2[100005];
LL tot[100005];
int main() {
    int t = 0;
    cin >> t;
    while (t--) {
        int n, k, z;
        LL ans = 0;
        cin>>n>>k>>z;
        LL tt = 0;
        for (int i = 0; i < n; ++i) {
            scanf("%d", a+i);
            if(i)tt += a[i];
            tot[i] = tt;
        }
        LL a2 = 0;
        for (int i = 0; i < n - 1; ++i) {
            a2 = max(a2, a[i] + a[i+1]);
            maxA2[i] = a2;
        }
        ans = tot[k];
        for (int i = 1; i <= k; ++i) {
            int rep = min(z, (k - i) / 2);
            if(k == i + rep * 2) ans = max(ans, maxA2[i - 1] * rep + tot[i]);
            if(k == i + 1 && z) ans = max(ans, tot[i] + a[i-1]);
            if(k == i + 1 + rep * 2 && z >= rep + 1) ans = max(ans, maxA2[i - 1] * rep + tot[i] + a[i-1]);
        }
        cout<<ans + a[0]<<endl;
    }
 
}

C.Good String

https://codeforces.com/contest/1389/problem/A 题意:找到[l, r]范围内的两个数x, y使得其最小公倍数也在[l, r]范围内。

点击以显示 ⇲

点击以隐藏 ⇱

 

D.Segment Intersections

https://codeforces.com/contest/1389/problem/A 题意:找到[l, r]范围内的两个数x, y使得其最小公倍数也在[l, r]范围内。

点击以显示 ⇲

点击以隐藏 ⇱

 

E.Segment Intersections

2020-2021/teams/too_low/cfedu92hj.1596187219.txt.gz · 最后更改: 2020/07/31 17:20 由 jim