P6051 [RC-02] Summation

Description

Xiao Q gives you several lines of strings. Each string contains some integers, and there may be other characters between the integers. You need to output the sum of all integers in each line. If a line contains no numbers at all, do not output anything for that line. **There is guaranteed to be at least one separator character between every two integers (see sample $3$).** Please note that the integers in this problem are simple integers, meaning there are no extra symbols before an integer. If the testdata contains `.`, treat it as a separator.

Input Format

Each line contains one string.

Output Format

For each string that contains integers, output one line with one number: the sum of the integers in that string.

Explanation/Hint

【Sample Explanation】 - In the first sample, the first line contains $57,54,-321,8$, and their sum is $-202$. The second and third lines contain no digits. The fourth line contains only one number $4$, so output $4$. - In the second sample, there is only one line, containing two numbers, and the sum is $4532893$. - In the third sample, for the first line, since there is guaranteed to be a separator character between every two integers, `-` is treated as a separator, so output $2$. For the fifth line, the first number is $-1$, so the second `-` is treated as a separator, and the sum is $-1+1=0$. For the seventh line, treat `.` as a separator, so the sum is $-2+3=1$. 【Constraints】 Note: “Condition A” means there are no other characters in the testdata except digits, spaces, newlines, and horizontal tabs. “Condition B” means every two numbers are separated by exactly one space. **Since the data is created on Windows, there may be extra `\r` characters at the end of lines. Please be careful.** For $10\%$ of the data, Conditions A and B are satisfied, and each line has exactly $10$ numbers. For $40\%$ of the data, Conditions A and B are satisfied, and there are no empty lines. For $50\%$ of the data, Conditions A and B are satisfied. For $70\%$ of the data, Condition A is satisfied. For $100\%$ of the data, there are no invisible characters other than horizontal tabs, spaces, and newlines. Each line has at most $1000$ characters, each line contains at most $200$ integers, there are at most $100$ lines, and each integer is $\in[-10^7,10^7]$. Translated by ChatGPT 5