文章

4

粉丝

0

获赞

17

访问

2.3k

头像
统计字符数 题解:
P5293 北京大学2025年机试题
发布于 2026年3月
阅读数 504

#include<bits/stdc++.h>
using namespace std;


int main(){
    string str;
    cin>>str;
    unordered_map<char,int>map;
    for(char c:str){
        map[c]++;
    }
    int max=-1;
    char best_char = 0;
    for(auto const&x:map){
        char c=x.first;
        int count=x.second;
        if(count>max){
            max=count;
            best_char=c;
        }else if(count==max){
            if(c<best_char){
                best_char=c;
        ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发