Lucas·Charlie @ 2017-11-18 21:45:42
#include<stdio.h>
int change(int a,int b)
{
if(a>b)
return b;
else if(a==b)
return a;
else if(a<b)
return a;
}
int main()
{
long long n,q,i,j,number[1001],need,lb,min=0,num=0,lon[10]={0,10,100,1000,10000,100000,1000000,10000000};
scanf("%d %d",&n,&q);
for(i=1;i<=n;i++)
{
scanf("%d",&number[i]);
}
for(i=1;i<=q;i++)
{
scanf("%d %d",&lb,&need);
for(j=1;j<=n;j++)
{
if(number[j]%lon[lb]==need)
num=change(min,number[j]);
}
if(num)
printf("%d\n",&lb);
else
printf("0\n");
}
return 0;
}
by Dr_殇 @ 2017-11-18 21:59:58
小兄弟,没有数-1,不是0,QAQ
by Dr_殇 @ 2017-11-18 22:00:30
@Lucas·Charlie 小兄弟,没有输-1,不是0,QAQ
by Lucas·Charlie @ 2017-11-19 14:29:05
额(⊙﹏⊙),发错了
#include<stdio.h>
int change(int a,int b)
{
if(a>b)
return b;
else if(a==b)
return a;
else if(a<b)
return a;
}
int main()
{
int n,q,i,j,number[1001],need,lb,min=0,num=0,lon[10]={0,10,100,1000,10000,100000,1000000,10000000};
scanf("%d %d",&n,&q);
for(i=1;i<=n;i++)
{
scanf("%d",&number[i]);
}
for(i=1;i<=q;i++)
{
scanf("%d %d",&lb,&need);
for(j=1;j<=n;j++)
{
if(number[j]%lon[lb]==need)
num=change(min,number[j]);
}
if(num)
printf("%d\n",&min);
else
printf("-1\n");
}
return 0;
}