Frequently Asked Questions
常见问题及解答
从哪里进行输入输出?
在你的程序里用标准输入输出,例如在C语言中,请用scanf和printf;对于C++语言,请用cin和cout(当然,scanf和printf也是可以的). 请不要进行文件读写操作,否则你将得到一个Runtime Error,并被系统记录为恶意攻击.
程序的返回值是多少?
对于C/C++程序,main()函数请声明为int类型,并返回0。如果为void类型,你将得到一个Comipler Error.
对于Judge的各种返回值有什么解释?
各个值的含意如下:
Queuing: 你的程序正在等待Judge,请过一会再刷新,查看结果
Running: 您的程序正在运行
Compiling: 您提交的代码正在被编译
Accepted: 恭喜,你的程序通过了Judge
Presentation Error: 你的结果是正确的,但是输出格式上有一点问题
Wrong Answer: 你的结果和标准答案不一致
Runtime Error: 运行时出错,例如栈溢出,除零,文件读写,非法内存操作,试途修改系统。main函数返回值不是0也可能提示本错误
Time Limit Exceeded: 超时错,你的程序没有在规定的时间内运行结束
Memory Limit Exceeded: 你的程序用的内存超过了限定
Output Limit Exceeded: 你的程序输出超过了限制, 这通常是死循环造成的
Comiple Error: 编译错误
System Error: OJ内部出现错误。由于我们的OJ可能存在一些小问题,所以出现这个信息请原谅,同时请及时与管理员联系。
系统支持哪几种编译器?
我们提供了C/C++编译器。版本为:g++ / gcc 3.4.2 (mingw-special)
我们还提供了Pascal编译器。版本为: FreePascal 2.2.2
另外 csc: 可以编译 .net framework 2.0/1.1 下运行的C#
例如:对于 Problem 1000
/* C 程序 */
#include
int main()
{
int a,b;
while(scanf("%d%d",&a,&b) != EOF)
printf("%d\n",a+b);
return 0;
}
// C++ 程序
#include
using namespace std;
int main()
{
int a,b;
while(cin >> a >> b)
cout << a+b <
return 0;
}
{ Pascal 程序 }
Program p1000(Input,Output);
var
a,b:Integer;
begin
while not eof(Input) do
begin
Readln(a,b);
Writeln(a+b);
end;
end.
// C# 程序 (C# on .Net 2.0)using System;class Program
{
static void Main(string[] args)
{ while (true) { string strInput = Console.ReadLine();
if (String.IsNullOrEmpty(strInput)) break;
string[] inputs = strInput.Split(" ".ToCharArray());
int a = int.Parse(inputs[0]);
int b = int.Parse(inputs[1]);
Console.WriteLine(a + b);
}
}
}
为什么我的程序在VC++/VC下能正常编译,但是在OJ上使用就会出现'Compilation Error'?
GNU 和 MS-VC++ 有所不同, 例如:
1) main() must be declared as int, void main() will end up with a Compile Error.
2) i is out of definition after block "for(int i=0...){...}"
3) itoa is not an ANSI function.
如何使用 64-bit integer?
__int64 a;
unsigned __int64 b;
long long a;
unsigned long long b;
输入:
scanf("%I64d", &x);scanf("%I64u", &x);
或
cin >> x;
输出:
printf("%I64d", x);printf("%I64u", x);
或
cout << x;
有什么预编译指令能使我的程序段不会被执行?
您可以使用ONLINE_JUDGE这个条件定义。下面是使用举例:
#ifndef ONLINE_JUDGE
此间的语句不会在判题系统中被执行(编译)
#endif