F.A.Q / 常见问题解答
Q Which programming languages can I use and what are the compiler options?
            A Online Judge supports C, C++ and Java, and uses GCC, G++ and JDK6 compiler. The version and compile options are:
            
        - GCC (v4.7.2): gcc.exe src.c -o test.exe
 - G++ (v4.7.2): g++.exe src.c -o test.exe
 - JDK6 (Update 45): javac.exe -encoding utf-8 Main.java
 
Q How can I write program at Online Judge?
            A Your program should read input from stdin("Standard Input") and write output to stdout("Standard Output").
            
            
            
        This is a sample solution for the A + B problem (Problem 1000) in the C language:
And the same problem in C++:
And the same problem in Java:
Q What are the meanings of the judge's replies?
            A Here is a list of the Judge's replies and their meaning:
            
        - Pending / Rejudge Pending: Your program is in the waiting queue, please wait a moment.
 - Judging: Your program is judging on the server.
 - Compile Error: The compiler fails to compile your program, you can view more information in "Online Status".
 - Runtime Error: Your program failed during the execution, you can view more information in "Online Status".
 - Time Limit Exceeded: Your program tried to run during too much time.
 - Memory Limit Exceeded: Your program tried to use more memory than the judge default settings.
 - Output Limit Exceeded: Your program tried to write too much information. Be sure that your program has no infinite loop.
 - Wrong Answer: Your output is incorrect. Note that, the judging data is far difficult than the sample.
 - Presentation Error: Your output format is not exactly the same as the sample output. Check your output for spaces and blank lines.
 - Accepted: Your program is correct and has passed the test.
 
Q Why did my C / C++ problem get a Compile Error?
            A The judger use GCC / G++ complier, that may be different from VC++, for example:
            
        - The main function must be declared as int, and you must return 0 at the end of main function, and void main will end up with a Compile Error.
 - The function itoa is not in ANSI Standard, so you need to use other solution.
 - The 64-bit integer __int64 is not in ANSI Standard, you can use long long instead. Because we use Windows operation system, you should use "%I64d" instead of "%lld", if you use scanf and printf.
 
Q How can I read input data until the end?
            A If you meet a problem doesn't give the number of case, You can do it like this:
            
                
                    
                
                
                    
                        
                            
                        
                            
                        
                            
                    
                    
                        
                            
                        
                            
                        
                            
                    
                    
                        
                            
                        
                            
                        
                            
                    
                
            
        
        
                            To read numbers
                        
                        
                                C
                            
                            int n;
while(scanf("%d", &n) != EOF)
{
  //Do Something
}
                        
                                C++
                            
                            int n;
while (cin >> n)
{
  //Do Something
}
                        
                                Java
                            
                            Scanner in = new Scanner(System.in);
while (in.hasNextInt()){
    int n = in.nextInt();
    //Do Something
}
                        
                            To read characters
                        
                        
                                C
                            
                            char w;
while ((w = getchar()) != EOF)
{
  //Do Something
}
                        
                                C++
                            
                            char w;
while (cin.get(w))
{
  //Do Something
}
                        
                                Java
                            
                            Scanner in = new Scanner(System.in);
while (in.hasNext()){
    string w = in.next();
    //Do Something
}
                        
                            To read lines
                        
                        
                                C
                            
                            char l[1024];
while(gets(l))
{
  //Do Something
}
                        
                                C++
                            
                            string l;
while (getline(cin, l))
{
  //Do Something
}
                        
                                Java
                            
                            Scanner in = new Scanner(System.in);
while (in.hasNextLine()){
    string l = in.nextLine();
    //Do Something
}
                        Q What is the maximum size of program that can be submitted?
            A The maximal size of program is 32767 bytes (32KB).