蓝桥杯备战5.图书管理员

NOIP2017图书管理员 (nowcoder.com)

cpp 复制代码
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N =2e5+10,M=1e3+10;
int a[N];
int n,q;
int check(int l,int x)
{
	int tmp=pow(10,l);
	for(int i=1;i<=n;i++)
	{
		if(a[i]%tmp==x)
		{
			cout<<a[i]<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}
signed main()
{
    std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
   	cin>>n>>q;
   	for(int i=1;i<=n;i++)cin>>a[i];//book bianma
    sort(a+1,a+1+n);
    while(q--)
    {
    	int l,x;cin>>l>>x;
    	check(l,x);
	}
    return 0;
}
相关推荐
aqiu1111116 天前
【数位 DP / 记忆化搜索】蓝桥云课 - 光轨区的 AI 数 题解
c++·算法·蓝桥杯·数位dp
aqiu1111118 天前
【并查集 / 图论】蓝桥云课 - 魔法大陆的城市群(求无向图连通块数量)题解
蓝桥杯·图论
aqiu1111118 天前
【LeetCode 902】最大为 N 的数字组合 - 详细题解与数位组合思路
数据结构·算法·leetcode·蓝桥杯·数位dp
Chester_199910 天前
CSP202312C.树上搜索
开发语言·数据结构·c++·蓝桥杯·stl
CoderYanger11 天前
A.每日一题:3622. 判断整除性
java·程序人生·算法·leetcode·面试·职场和发展·蓝桥杯
Chester_199912 天前
CSP202303C.LDAP
开发语言·c++·蓝桥杯·stl
Chester_199916 天前
CSP202206C.角色授权
开发语言·数据结构·c++·蓝桥杯
Chester_199916 天前
CSP202203C.计算资源调度器
开发语言·数据结构·c++·蓝桥杯
Chester_199920 天前
CSP202104C.DHCP服务器
开发语言·程序人生·蓝桥杯
_Narcissus_23 天前
二分算法笔记及例题
数据结构·c++·笔记·算法·蓝桥杯·查找·二分算法