金山1022笔试第三题有人100吗?测试案例全通过,结果0

bool isYuan(char c) {
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') return true;
    return false;
}
int main() {
    string s;
    cin >> s;
    int n = s.size(), yuan = 0, fu = 0;
    for (int i = 0; i < n; i++) {
        if (isYuan(s[i])) yuan++;
        else fu++;
    }
    if (fu >= yuan + 1) {
        cout << 2 * yuan + 1 << endl;
        return 0;
    }
    else {
        cout << yuan + fu << endl;
        return 0;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int>a(n);
    vector<char>ans(n, 'c');
    unordered_map<int, int>valToIndex;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        valToIndex[a[i]] = i;
    }
    sort(a.begin(), a.end());
    int flag = 1;
    char c = 'c';
    for (int i = n - 1; i >= 0; i--) {
        int id = valToIndex[a[i]];
        if (ans[id] != 'c') continue;
        if (flag == 1) c = 'A';
        else if (flag == -1) c = 'B';
        ans[id] = c;
        if (m != 0) {
            for (int j = id + 1, cnt = 0; j < n && cnt < m; j++) {
                if (ans[j] == 'c') {
                    ans[j] = c;
                    cnt++;
                }
            }
            for (int j = id - 1, cnt = 0; j >= 0 && cnt < m; j--) {
                if (ans[j] == 'c') {
                    ans[j] = c;
                    cnt++;
                }
            }
        }
        flag = -flag;
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i];
    }
    return 0;
}

#include <iostream>
using namespace std;
#include <bits/stdc++.h>
using ll = long long;
int M = pow(10, 9) + 7;
int main() {
    ll h, x;
    cin >> h >> x;
    vector<ll>a(h);
    ll ans = 0;
    for (ll i = 0; i < h; i++) {
        cin >> a[i];
        ans += a[i] * pow(x, i + 1);
    }
    cout << ans % M << endl;
    return 0;
}

全部评论
我只有第三题百分百,其他俩都没做 因为我晚进了半个钟
1 回复 分享
发布于 2023-10-23 00:01 湖北
第三题应该是测试用例数字都比较大,计算过程中会超范围
点赞 回复 分享
发布于 2023-10-22 22:22 上海
我也是,感觉很离奇,读来读去不知道哪里错了
点赞 回复 分享
发布于 2023-10-22 21:12 湖北

相关推荐

野猪不是猪🐗:还是太卑微了,什么叫放弃本次面试应该说经过评估,贵公司与自己不匹配,决定不再推进后续流程
点赞 评论 收藏
分享
今天 00:37
已编辑
山东大学 C++
小浪_Coding:你问别人,本来就是有求于人,别人肯定没有义务免费回答你丫, 有点流量每天私信可能都十几,几十条的,大家都有工作和自己的事情, 付费也是正常的, 就像你请别人搭把手, 总得给人家买瓶水喝吧
点赞 评论 收藏
分享
评论
点赞
7
分享

创作者周榜

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