1 条题解
-
0
Java :
import java.util.Scanner; public class Main { static char a[][] = new char[1001][1001]; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int book[] = new int[1001]; int len[] = new int[1001]; int num[] = new int[1001]; int n = sc.nextInt(); int q = sc.nextInt(); for(int i=1;i<=n;i++){ book[i] = sc.nextInt(); } for(int i=1;i<=q;i++) { len[i] = sc.nextInt(); num[i] = sc.nextInt(); // 10的 len[i]次方 int tmp = (int) Math.pow(10,len[i]),min=Integer.MAX_VALUE; for(int j=1;j<=n;j++) { if(book[j]%tmp==num[i]&&book[j]<min){ min=book[j]; } } if(min!=Integer.MAX_VALUE){ System.out.println(min); }else{ System.out.println(-1); } } sc.close(); } }
- 1
信息
- ID
- 2482
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 5
- 标签
- 递交数
- 129
- 已通过
- 50
- 上传者