ACM type input

In ACM/OJ problems you usually adapt input/output handling rather than writing a main() that parses arguments. Here’s a clean Python pattern using sys.stdin.

import sys

for line in sys.stdin:                 # Read from standard input, line by line, until EOF
    if not line.strip():               # Skip empty or all-whitespace lines
        continue

    nums = list(map(int, line.split()))  # Split on whitespace and convert tokens to int
    # TODO: process nums常默认输入合法,所以不额外处理。
本文阅读:--
访客:-- 浏览:--