Educational Codeforces Round 171 (Rated for Div. 2)

https://codeforces.com/contest/2026

A:

思路:我的是算最小的边mi,两个线段从原点向X,Y轴,呈L形,再不断+1直到一边大于k

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
void solve()
{
    int x, y, k;
    cin >> x >> y >> k;
    if (x >= k && y >= k){
        cout << 0 << " " << 0 << " " << 0 << " " << k << endl;
        cout << 0 << " " << 0 << " " << k << " " << 0 << endl;
        return ;
    }
    int mi = min(x, y), p = 1;

    while (mi*mi + p*p < k*k){
        p++;
    }
    // cout << mi*mi + p*p << endl;
    cout << 0 << " " << 0 << " " << p << " " << mi << endl;
    cout << 0 << " " << p << " " << mi << " " << 0 << endl;
    
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    
    return 0;
}

赛后看榜发现只要求min(𝑋, Y)的正方形的两条对角线就可以了,因为题目一定有答案,感兴趣可以试试。

B:

思路:很典的二分题

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define endl '\n'
#define fo(i,l,r) for(int i=(l);i<=(r);++i)
const int INF = 1e18;
void solve()
{
    int n;
    cin >> n;
    vi a(n+2);
    fo(i,1,n) cin >> a[i];
    a[n+1] = 4e18;
    auto check = [&](int x)->bool
    {
        int cnt = 0;
        for (int i=1; i<=n; i++){
            if (a[i+1]-a[i] <=x){
                i++;
                continue;
            }
            else cnt++;
        }
        return cnt <= 1;
    };
    int l = 0, r = INF;
    while (l+1<r){
        int mid = (l+r)/2;
        if(check(mid)){
            r = mid;
        }
        else{
            l = mid;
        }
    }
    cout << r << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    
    return 0;
}

C:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define endl '\n'
#define fo(i, l, r) for (int i = (l); i <= (r); ++i)
void solve()
{
    int n, m, k;
    cin >> n;
    string s;
    cin >> s;
    s = "0" + s;
    if (n == 1){
        cout << 1 << endl;
        return ;
    }
    int res = 0;
    int cnt=0;
    for (int i = 1; i<=n; i++){
        res += i;
    }
    for (int i = n; i >=2; i--)
    {
        if (s[i] == '1' && i-1>=cnt+1){
            cnt++;
            res -= i;
            
        }
        if (s[i]=='0'&&cnt){
            cnt--;
        }
    }
    cout << res << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

D:

思路:数学题,推公式

E:

思路:网络流,不会的得去学一手。

正在更新...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wirepuller_king

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值