第十四届蓝桥杯三月真题刷题训练——第 18 天 (3.21)

Think_bird 2023-03-21 21:29:45

排列字母

#include<bits/stdc++.h>

using namespace std;

int main()
{
    char s[] = "WHERETHEREISAWILLTHEREISAWAY";
    sort(s, s + 28);
    cout << s;
    return 0;
}

GCD

#include <iostream>

using namespace std;

long long a, b;

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> a >> b;
    cout << b - a - (a % (b - a));

    return 0;
}

选数异或 

#include<iostream>
using namespace std;
const int N = 1e5 + 5;
int a[N], Left[N];
int pos[(1 << 20) + 10];//空间换时间
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        Left[i] = pos[a[i] ^ x];
        pos[a[i]] = i;
    }
    while (m--)
    {
        int l, r;
        bool bl = false;
        cin >> l >> r;
        for (int i = l; i <= r; i++)
        {
            if (Left[i] >= l )
            {
                bl = true;
                break;
            }
        }
        if (bl)
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    return 0;
}

 

...全文
15 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

51,733

社区成员

发帖
与我相关
我的任务
社区描述
和众多高校算法内卷分子,一起学习和交流算法那。浓郁的算法交流氛围,拒绝躺平,有效内卷。加入我们,私信我拉你入核心内卷群。
算法数据结构leetcode 个人社区
社区管理员
  • 执 梗
  • Dream-Y.ocean
  • ღCauchyོꦿ࿐
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

 刷题!

试试用AI创作助手写篇文章吧