为什么运行不了

为什么这个运行不了

import java.util.Scanner;

public class Main {public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int k = sc.nextInt();
    long[] a = new long[n];
    boolean[] v = new boolean[n];
    long maat = 0;
    int c = 0;
    for (int i = 0; i < n; i++) {
        a[i] = sc.nextLong();
    }

    for (int i = 0; i < n; i++) {
        if (!v[i]) {
            for (int j = 0; j < n; j++) {
                if (v[j]) continue;
                int x = (int) ((a[i] + a[j]) % k);
                if (x==0) {
                    c=c+1;
                    v[i] = true;
                    v[j] = true;
                }
            }
        }
    }
    System.out.println(c);
}

全部评论

相关推荐

独玖:同二本,建议咱俩一起重开
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务