yigeshabi @ 2023-10-17 16:23:20
#include<bits/stdc++.h>
using namespace std;
int main()
{
int shu[1001],gu=1e7,w,h,m,n;
cin>>m>>n;
for(int i=1;i<=m;i++) cin>>shu[i];
for(int i=1;i<=n;i++){
gu=1e7;
cin>>w>>h;
for(int i2=1;i2<=n;i2++)
if(h==shu[i2]%(int)pow(10,w)) gu=min(gu,shu[i2]);
if(gu==1e7) cout<<"-1"<<endl;
else cout<<gu<<endl;
}
return 0;
}
by HLR20120422 @ 2023-10-17 16:48:42
#include<bits/stdc++.h>
using namespace std;
struct book
{
int w;
int num;
}
a[1000+1];
int i,j,k,l,n,m,b[1000+1];
int ask(int x,int a,int y)
{
int sz=a;
int w=1;
do
{
w*=10;
sz--;
}
while(sz!=0);
if((x%=w)==y)
return 1;
else return 0;
}
int main()
{
cin>>n>>m;
for(i=1;i<=n;i++)
{
cin>>b[i];
}
sort(b+1,b+n+1);
for(i=1;i<=m;i++)
{
cin>>a[i].w>>a[i].num;
}
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
k+=ask(b[j],a[i].w,a[i].num);
if(ask(b[j],a[i].w,a[i].num)==1)
break;
}
if(k==0)
cout<<"-1"<<endl;
else
cout<<b[j]<<endl;
k=0;
}
return 0;
}
by HLR20120422 @ 2023-10-17 16:52:20
我这个小鞋生都会做,您属实有一点辣鸡,这个代码肯定满分
by Breath_of_the_Wild @ 2023-10-17 16:58:48
第
by yigeshabi @ 2023-10-17 17:41:44
@Breath_of_the_Wild 谢谢
by Restart_Justin @ 2024-01-06 12:05:00
@2021Changqing48 把你的个性签名改一下(