guoyichen_guoyichen @ 2024-10-11 21:35:25
by guoyichen_guoyichen @ 2024-10-11 21:43:12
新手不懂如何发代码
by 7wny @ 2024-10-13 16:03:58
哪道题
by guoyichen_guoyichen @ 2024-10-14 15:16:04
3955
by guoyichen_guoyichen @ 2024-10-14 16:10:24
by 7wny @ 2024-10-14 21:07:45
#include<bits/stdc++.h>
using namespace std;
int n,q,len,a[1000005],s;
int main(){
// freopen("librarian.in","r",stdin);
// freopen("librarian.out","w",stdout);
scanf("%d%d",&n,&q);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
sort(a+1,a+n+1);
for(int i=1;i<=q;i++){
scanf("%d%d",&len,&s);
int j;
for(j=1;j<=n;j++)if(a[j]%(int)pow(10,len)==s){printf("%d\n",a[j]);break;}
if(j>n)printf("-1\n");
}
// fclose(stdin);fclose(stdout);
return 0;
}
by kimigzr @ 2024-10-25 16:26:29
#include<bits/stdc++.h>
using namespace std;
int book[1010];
long long request;
int table[10000010];
int main(){
//freopen("librarian.in","r",stdin);
//freopen("librarian.out","w",stdout);
int n,q,l;
cin>>n>>q;
for(int i=1;i<=n;i++) cin>>book[i];
sort(book+1,book+n);
for(int i=n;i>=1;i--){
int c=book[i];
while(c){
table[c]=i;
c=c%int(pow(10,int(log10(c))));
}
}
book[0]=-1;
for(int i=0;i<q;i++){
cin>>l>>request;
cout<<book[table[request]]<<endl;
}
return 0;
}