帮助
评判
C++ 使用 g++ 9.4.0
编译,命令为
g++ -fno-asm -Wall -lm --static -O2 -std=c++14 -DONLINE_JUDGE -o Main Main.cc
;
C 使用 gcc 9.4.0
编译,命令为
gcc Main.c -o Main -fno-asm -Wall -lm --static -O2 -std=c99 -DONLINE_JUDGE
您可以使用 #pragma GCC optimize ("O0")
手工关闭 O2 优化;
Pascal 使用 fpc 3.0.4
编译,命令为
fpc Main.pas -oMain -O1 -Co -Cr -Ct -Ci
。
Java 使用 OpenJDK 17.0.4
编译,命令为
javac -J-Xms32m -J-Xmx256m Main.java
,如果您的代码中没有 public class
,请将入口类命名为 Main
,在评测时提供额外 2 秒的运行时间和 512MB 的运行内存。
这里给出的编译器版本仅供参考,请以实际编译器版本为准。
请使用标准输入输出。
Q: cin/cout为什么会超时(TLE)?
A: cin/cout因为默认同步stdin/stdout而变慢,并产生更多的系统调用而受到性能影响,可以在main函数开头加入下面代码加速:
ios::sync_with_stdio(false); cin.tie(0);
Q:gets函数没有了吗?
A:gets函数因为不能限制输入的长度,造成了历史上大量的缓冲区溢出漏洞,因此在最新版本中被彻底删除了,请使用fgets这个函数取代。 或者使用下面的宏定义来取代:
个人资料
本站不提供头像存储服务,而是使用 QQ 头像显示。请使用QQ邮箱注册 ,系统自动取用您在QQ的头像。
返回结果说明
试题的解答提交后由评判系统评出即时得分,每一次提交会评判结果会及时通知;系统可能的反馈信息包括:
英文输出 | 英文缩写 | 中文输出 | 含义 |
Pending | 等待评判 | 系统忙,你的答案在排队等待评判。 | |
Pending Rejudge | 等待重判 | 因为数据更新或其他原因,系统将重新判你的答案。 | |
Compiling | 编译中... | 正在编译。 | |
Running & Judging | 运行&评判中... | 正在运行和评判。 | |
Accepted | AC | 答案正确 | 程序通过! |
Presentation Error | PE | 格式错误 | 答案基本正确,但是格式不对。 |
Wrong Answer | WA | 答案错误 | 答案不对,仅仅通过样例数据的测试并不一定是正确答案,一定还有你没想到的地方。 |
Time Limit Exceeded | TLE | 时间超限 | 运行超出时间限制,检查下是否有死循环,或者应该有更快的计算方法。 |
Memory Limit Exceeded | MLE | 内存超限 | 超出内存限制,数据可能需要压缩,检查内存是否有泄露。 |
Output Limit Exceeded | OLE | 输出超限 | 输出超过限制,你的输出比正确答案长了两倍。 |
Runtime Error | RE | 运行错误 | 运行时错误,非法的内存访问,数组越界,指针漂移,调用禁用的系统函数。请点击后获得详细输出。 |
Compile Error | CE | 编译错误 | 编译错误,请点击后获得编译器的详细输出。 |
程序样例
以下样例程序可用于解决这道简单的题目:读入2个整数A和B,然后输出它们的和。
题目网址:https://ttt.org.cn/item/1000
gcc (.c)
#include <stdio.h>
int main(){
int a, b;
while(scanf("%d %d",&a, &b) != EOF){
printf("%d\n", a + b);
}
return 0;
}
g++ (.cpp)
#include <iostream>
using namespace std;
int main(){
// io speed up
const char endl = '\n';
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b;
while (cin >> a >> b){
cout << a+b << endl;
}
return 0;
}
fpc (.pas)
var
a, b: integer;
begin
while not eof(input) do begin
readln(a, b);
writeln(a + b);
end;
end.
javac (.java)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextInt()) {
int a = in.nextInt();
int b = in.nextInt();
System.out.println(a + b);
}
}
}
python3 (.py)
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf8')
for line in sys.stdin:
a = line.split()
print(int(a[0]) + int(a[1]))