Windy0430 @ 2024-10-21 22:53:51
#include <bits/stdc++.h>
#include <cstdio>
#define ll long long
using namespace std;
ll n , q , books[1001] , read , num = 0;
int lenth;
void abc(ll &a , ll &b){
ll c = 0;
c = b;
b = a;
a = c;
}
int main(){
//freopen(".in" , "r" , stdin);
//freopen(".out" , "w" , stdout);
scanf("%ld %ld" , &n , &q);
for(int i = 1 ; i <= n ; i++){
scanf("%ld" , &books[i]);
}
for(int i = 1 ; i <= n ; i++){
for(int j = 1 ; j < n ; j++){
if(books[j] > books[j + 1]){
abc(books[j] , books[j + 1]);
}
}
}
for(int i = 1 ; i <= q ; i++){
scanf("%d %ld" , &lenth , &read);
for(int j = 1 ; j <= n ; j++){
int a = pow(10 , lenth);
if(books[j] % a == read){
printf("%ld\n" , books[j]);
books[j] = -1;
num++;
break;
}
}
if(num == 0){
printf("-1\n");
}
num = 0;
}
return 0;
}
by Windy0430 @ 2024-10-21 22:59:24
求助
by haiqian @ 2024-10-21 23:08:41
@Windy0430
第 ll read
变量名改一下就可以了
read
是istream
里的函数原型
istream& read (char* s, streamsize n)
link
用万能头的弊端
by haiqian @ 2024-10-21 23:12:42
@Windy0430
另,建议尽量不要用简单常用的英文单词起变量名,比较容易与万能头里的函数,关键字重名
比如 new
, function
, catch
等等
by Windy0430 @ 2024-10-23 22:06:24
@haiqian 谢谢