首页 > 360下午笔试 20分钟AK 真的划水
头像
我是7号
发布于 2020-08-24 14:57
+ 关注

360下午笔试 20分钟AK 真的划水

第一题
#include<iostream>
#include<set>
#include<string>
using namespace std;
int main() {
    set<char> chars{ 'A','H','I','M','O','T','U','V','W','X','Y' };
    string s;
    while (cin >> s) {
        bool isTrue = true;
        int left = 0, right = s.size()-1;
        while (left <= right) {
            if (s[left] != s[right] || chars.find(s[left]) == chars.end()) {
                isTrue = false;
                break;
            }
            left++;
            right--;
        }
        if (isTrue) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

第二题
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> vec;
    long long sum = 0;
    while (n--) {
        int a, b;
        cin >> a >> b;
        if (b == 0) sum += a;
        else vec.push_back(a);
    }
    sort(vec.begin(), vec.end());
    for (int i = vec.size() - 1; i >= 0; i--) {
        if (vec[i] > sum) sum+=vec[i];
        else sum *= 2;
    }
    cout << sum << endl;
}

全部评论

(0) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

近期热帖

近期精华帖

热门推荐