Java中的Gild代码编译失败

时间:2021-01-05 07:01:31

I am submitting my code for Euler10 puzzle at Gild.com in Java using its online editor. The code runs perfectly for all test cases on my PC but compilation on Gild fails. I am following all of its coding rules but I think I'm still missing something. Here's my code:

我正在使用其在线编辑器在Gild.com上用Java提交我的Euler10拼图代码。代码在我的PC上运行完全适用于所有测试用例,但Gild上的编译失败。我遵循所有的编码规则,但我想我仍然缺少一些东西。这是我的代码:

class Euler10 {

public static void main(String[] args) throws java.lang.Exception
{
    java.io.BufferedReader br = new java.io.BufferedReader (new java.io.FileReader(args[0]));
    int number = Integer.parseInt(br.readLine());
    boolean[] isPrime = new boolean[number + 1];
    for (int i = 2; i <= number; i++)
        isPrime[i] = true;
    for (int i = 2; i*i <= number; i++)
    {
        if (isPrime[i])
        {
            for (int j = i; i*j <= number; j++)
                isPrime[i*j] = false;
        }
    }
    long primesum = 0;
    for (int i = 2; i < number; i++)
    {
       if (isPrime[i])
          primesum = primesum+i;
    }
    System.out.println(""+primesum+"\n");
}

}


After compiling this code in debug mode, I get the following error:

在调试模式下编译此代码后,我收到以下错误:

Java中的Gild代码编译失败


My program output shown above is same as the test case output even though it gives wrong result.
Also tell me what is a Diff Output in this context.

(I want to submit the code in the online editor only.)

Gild coding Puzzle FAQs &
Submission guidelines

Thanks

上面显示的程序输出与测试用例输出相同,即使它给出了错误的结果。还告诉我在这种情况下什么是Diff Output。 (我想仅在在线编辑器中提交代码。)Gild编码拼图常见问题解答和提交指南谢谢

2 个解决方案

#1


0  

It seems that the problem is that your output is not identical to the expected output. Try replacing your last line System.out.println(""+primesum+"\n"); with (System.out.println(""+primesum);

似乎问题是您的输出与预期输出不同。尝试替换最后一行System.out.println(“”+ primesum +“\ n”); with(System.out.println(“”+ primesum);

#2


0  

Your program produces the wrong result, and (1) you don't tell us what it's supposed to do, nor do you (2) show us your program. Are we psychics here?

你的程序产生了错误的结果,(1)你没有告诉我们它应该做什么,你也没有(2)告诉我们你的程序。我们这里是通灵者吗?

Anyway, the diff (short for difference) output is showing you that either there's a newline at the end of your output, and it's not supposed to be there, or possibly the other way around -- you'd have to read the "help reading diff output" link.)

无论如何,diff(差异的缩写)输出显示你输出结尾有一个换行符,它不应该在那里,或者可能反之亦然 - 你必须阅读“帮助”读取差异输出“链接。)

Does that help?

这有帮助吗?

#1


0  

It seems that the problem is that your output is not identical to the expected output. Try replacing your last line System.out.println(""+primesum+"\n"); with (System.out.println(""+primesum);

似乎问题是您的输出与预期输出不同。尝试替换最后一行System.out.println(“”+ primesum +“\ n”); with(System.out.println(“”+ primesum);

#2


0  

Your program produces the wrong result, and (1) you don't tell us what it's supposed to do, nor do you (2) show us your program. Are we psychics here?

你的程序产生了错误的结果,(1)你没有告诉我们它应该做什么,你也没有(2)告诉我们你的程序。我们这里是通灵者吗?

Anyway, the diff (short for difference) output is showing you that either there's a newline at the end of your output, and it's not supposed to be there, or possibly the other way around -- you'd have to read the "help reading diff output" link.)

无论如何,diff(差异的缩写)输出显示你输出结尾有一个换行符,它不应该在那里,或者可能反之亦然 - 你必须阅读“帮助”读取差异输出“链接。)

Does that help?

这有帮助吗?