Codeforces Round #560 (Div. 3)简要题解

A - Remainder

倒着看s,第y位是1,其余<x的都是0,判断一下即可。

#include "bits/stdc++.h"

using namespace std;
long long a[200004];

int main() {
    int n,x,y;
    cin>>n>>x>>y;
    string s;
    cin>>s;
    int cnt=0;
    int ans=0;
    for (int i = s.length()-1; cnt<x ; --i,++cnt) {
        if(cnt==y)ans+=s[i]!='1';
        else ans += s[i]=='1';
    }
    cout<<ans<<endl;
}

B - Polycarp Training

排序判断一下就可以了。

#include "bits/stdc++.h"

using namespace std;
long long a[200004];

int main() {
    int n;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int d=1;
    for (int i = 0; i < n; ++i) {
        if(a[i]>=d)d++;
    }
    cout<<d-1<<endl;
}

C - Good String

如果当前是奇数位且后面是相同的那直接erase就可以了,最后判断一下奇偶。

#include "bits/stdc++.h"

using namespace std;
const int mod = 998244353;
long long a[200004];
long long b[200004];

int main() {
    int n;
    string s;
    cin>>n>>s;
    for (int i = 0; i < s.length(); ++i) {
        while((i+1)&1&&i+1<s.length()&&s[i+1]==s[i]){
            s.erase(s.begin()+i+1);
        }
    }
    if(s.length()&1)s.erase(--s.end());
    cout<<n-s.length()<<endl<<s<<endl;
}

D - Almost All Divisors

https://blog.csdn.net/qq_42671946/article/details/90234399

E - Two Arrays and Sum of Functions

https://blog.csdn.net/qq_42671946/article/details/90234387

F1 - Microtransactions (easy version)&&F2 - Microtransactions (hard version)

https://blog.csdn.net/qq_42671946/article/details/90234363

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值