9.14 百度B卷前两题AC(CPP版本)

1.倒转乘法表
#include <bits/stdc++.h>

using namespace std;

int rev(int in) {
    int out = 0;
    while (in) {
        out = out * 10 + in % 10;
        in /= 10;
    }
    return out;
}


int main () {
    int N, K;
    cin >> N >> K;
    int ret = 0;
    for (int i = 1; i <= K; i++) {
        int cur = rev(N * i);
        if (cur > ret) ret = cur;
    }
    cout << ret << endl;
    return 0;
}
2.共同区间
#include <bits/stdc++.h>

using namespace std;


int main () {
    string str;
    cin >> str;
    int l = 0, r = str.size() - 1;
    int lc = l, rc = r;
    while (l < rc && str[l] != str[rc]) rc--;
    while (lc < r && str[lc] != str[r]) lc++;
    if (rc - l < r - lc) {
        cout << lc + 1 << " " << r << " " << lc + 2 << " " << r + 1 << endl;
    } else {
        cout << l + 1 << " " << rc << " " << l + 2 << " " << rc + 1 << endl;
    }
    return 0;
}



#百度笔试##百度##笔经#
全部评论
就只有两道题?
点赞 回复 分享
发布于 2022-10-22 17:31 山西

相关推荐

05-26 10:24
门头沟学院 Java
qq乃乃好喝到咩噗茶:其实是对的,线上面试容易被人当野怪刷了
找工作时遇到的神仙HR
点赞 评论 收藏
分享
07-04 09:21
已编辑
Java
推拿大师:这是hr发的钓鱼贴吗
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-04 18:25
点赞 评论 收藏
分享
评论
点赞
2
分享

创作者周榜

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