java中的非零退出代码,在codechef上提交时,否则工作正常

时间:2015-07-07 11:26:07

标签: java

对于此代码,在codechef上根据查询执行不同的操作 我得到非零退出代码,但它在我的机器上工作正常。这是空间问题还是别的什么?我在StringTokenizer类中使用FastScanner进行快速输入。

FastScanner sc = new FastScanner();
int n = sc.nextInt();
int q = sc.nextInt();
BigInteger[] arr = new BigInteger[n];
String val, s;
for (int i = 0; i < n; i++) {
    arr[i] = new BigInteger("0");
}
BigInteger m = new BigInteger("1000000007");
for (int i = 0; i < n; i++) {
    s = sc.nextToken();
    arr[i] = new BigInteger(s);
}

while (q > 0) {
    int c = sc.nextInt();
    int st = sc.nextInt();
    int en = sc.nextInt();
    switch (c) {
        case 1: {
            val = sc.nextToken();
            BigInteger v = new BigInteger(val);

            for (int j = st - 1; j <= en - 1; j++) {
                arr[j] = arr[j].add(v);
                arr[j] = arr[j].mod(m);
            }
            break;

        }
        case 2: {
            val = sc.nextToken();
            BigInteger v = new BigInteger(val);
            for (int j = st - 1; j <= en - 1; j++) {
                arr[j] = arr[j].multiply(v);
                arr[j] = arr[j].mod(m);
            }
            break;

        }
        case 3: {
            val = sc.nextToken();

            for (int j = st - 1; j <= en - 1; j++) {
                arr[j] = new BigInteger("val");

            }
            break;

        }
        case 4: {
            BigInteger sum = new BigInteger("0");
            for (int j = st - 1; j <= en - 1; j++) {
                sum = sum.add(arr[j]);

            }
            sum = sum.mod(m);
            System.out.println(sum);

            break;
        }
    }
    q--;
}

0 个答案:

没有答案