蓝桥杯 对联

题意

代码

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

inline int read() {
    int ans = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')f = -1;
        ch = getchar();
    }
    while (ch <= '9' && ch >= '0') {
        ans = ans * 10 + ch - '0';
        ch = getchar();
    }
    return ans * f;
}
int main()
{
    int n= read();
    string s,t;
    cin>>s>>t;
    int cnts0 = 0,cnts1=0,cntt0=0,cntt1=0;
    for (auto e : s) {
        if (e=='0')cnts0++;
        else cnts1++;
    }
    for (auto e : t) {
        if (e=='0')cntt0++;
        else cntt1++;
    }
    cout<<(min(cnts0,cntt1)+min(cnts1,cntt0))<<"\n";
    return 0;
}

posted @ 2025-06-01 00:40  Guaninf  阅读(6)  评论(0)    收藏  举报