| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 71992 | 赵天瑜 | [在线测评解答教程] 求和 | Python3 | Accepted | 32 MS | 3768 KB | 439 | 2024-04-29 19:16:18 |
import sys def calculate_sum(n): # 计算 1 + 2 + ... + n 的和 return (n * (n + 1)) // 2 # 从标准输入逐行读取数据 input_data = sys.stdin.read().strip().split() for line in input_data: try: n = int(line) if 1 <= n <= 1000: result = calculate_sum(n) print(result) except ValueError: # 如果无法转换为整数,跳过该行 continue