Codeforces Round 871 (Div. 4) 全题题解

Codeforces Round 871 (Div. 4) 全题题解

那天晚上没来打【枯】要不然我就可以上 $1400$ 了。

A. Love Story

这应该是 ChatGPT 都会做的题,不会做你真的可以退役了。

定义字符串 $s=\texttt{codeforces}$,输入后枚举哪一个字符不匹配就答案加一。

//the code is from chenjh
#include<cstdio>
const char s[15]="codeforces";
char t[15];
void solve(){
    scanf("%s",t);
    int ans=0;
    for(int i=0;i<10;i++)ans+=s[i]!=t[i];
    printf("%d\n",ans);
}
int main(){
    int T;scanf("%d",&T);
    while(T--) solve();
    return 0;
}

B. Blank Space

从左向右依次枚举,如果 $a_i=1$ 就将答案取和当前长度最大,否则将当前长度加一。

//the code is from chenjh
#include<cstdio>
int n;
bool a[105];
inline int max(const int x,const int y){return x>y?x:y;}
void solve(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int ans=0,now=0;
    for(int i=1;i<=n;i++){
        if(a[i]) ans=max(ans,now),now=0;
        else now++;
    }
    printf("%d\n",max(ans,now));
}
int main(){
    int T;scanf("%d",&T);
    while(T--) solve();
    return 0;
}

C. Mr. Perfectly Fine

题解 CF1829C Mr. Perfectly Fine

D. Gold Rush

题解 CF1829D Gold Rush

E. The Lakes

题解 CF1829E The Lakes

F. Forever Winter

CF1829F Forever Winter 题解

G. Hits Different

题解 CF1829G Hits Different

H. Don't Blame Me

这道题我还没做,先看一下官方题解 Codeforces Round 871 (Div. 4) Editorial 或者 洛谷题解区的优质题解吧!

记得给我的题解点个赞!

posted @ 2023-05-10 19:48  Chen_Jinhui  阅读(68)  评论(0)    收藏  举报  来源