题解 | 小红的删数字

小红的删数字

https://www.nowcoder.com/practice/f7735f6d2e334c2d8fc7cb834526491d

#include <bits/stdc++.h>
using namespace std;
string x;
array<int, 3> cnt = {};
int sum;
bool f() {
    if (cnt[sum] == 0) {
        return 0;
    }
    cnt[sum]--;
    return cnt[0] && cnt[1] == cnt[2];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> x;
    for (auto c : x) {
        if (c != '0') {
            cnt[(c - '0') % 3]++;
            sum = (sum + (c - '0')) % 3;
        }
    }
    cout << (f() ? "kou" : "yukari");
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务