跳到正文

题解

题解:AT_scpc2026_div3_a Find the Missing Letter

ElysiaTruE约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年7月4日
收录
2026年10月4日
更新
2026年11月21日
篇幅
约 1 分钟

版本

  1. v1当前

在输入一个字符串 SCSC 时,不小心漏掉了一个字符,找出漏掉的字符。

我们发现 SCSC 这个字符串,恰好有两个 S,两个 C。于是,在字符串中,哪个字母只出现了一次,哪个字母就是少了一个的字母。

代码
C++
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a=0,b=0;
    string s;
    cin>>s;
    for(auto c:s){
        if(c=='S')a++;
        else if(c=='C')b++;
        else puts("轻松绷住");
    }
    if(a==1)cout<<"S";
    else if(b==1)cout<<"C";
    else puts("轻松绷住");
    return 67^67;
}
原文