#CCBCHBON0000009. Sequence of Numbers and Sum (Sequence of Numbers and Sum)
Sequence of Numbers and Sum (Sequence of Numbers and Sum)
Sequence of Numbers and Sum
Source: beecrowd
Version: Phuoc Hung OJ Extended
Problem Statement
Read pairs . For each pair with both values positive, print every integer from through , then Sum= immediately followed by their total. Stop at the first pair containing a nonpositive value without printing a line for it. Separate sequence terms and the final token with one space.
Input
One pair per line, with the final pair containing a nonpositive value. The PHOJ edition permits up to 50 valid pairs with values in ; each terminating value is in .
Output
One line L L+1 ... R Sum=S per valid pair. Empty output if there are no valid pairs.
Subtasks
-
Subtask 1 (20%): At most 3 valid pairs; valid pair values in .
-
Subtask 2 (30%): At most 12 valid pairs; valid pair values in .
-
Subtask 3 (50%): At most 50 valid pairs; valid pair values in .
Examples
Example 1
Input:
5 2
6 6
0 4
Output:
2 3 4 5 Sum=14
6 Sum=6
Explanation:
Sort each positive pair, print the inclusive sequence and its sum; do not print the sentinel pair.
Example 2
Input:
0 3
Output:
Explanation:
Sort each positive pair, print the inclusive sequence and its sum; do not print the sentinel pair.