投篮游戏

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/m0_37924505/article/details/80004670
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int p = sc.nextInt();
			int n = sc.nextInt();
			int[] x = new int[n];
			for(int i = 0;i<n;i++) {
				x[i] = sc.nextInt();
			}
			int re = -1;
			int[] res = new int[p];
			for (int i = 0; i < p; i++) {
				res[i] = i;
			}
			
			for (int i = 0; i < x.length; i++) {
				int j = x[i]%p;
				if(res[j]==-1) {
					re = i+1;
					break;
				}else {
					res[j] = -1;
				}
			}
			System.out.println(re);
			
		}
	}
	
}
q其实题目有点含糊
展开阅读全文

没有更多推荐了,返回首页