People's vaccine
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Zenyk loves drinking tea very much, because it is a good prevention against burdockvirus.
Zenyk takes tea drinking very responsibly, and therefore always follows strict rules: he drinks tea every hour, starting at 9 AM and ending at 9 PM, the volume of tea drunk is always an integer. In addition, Zenyk firmly believes that for a better effect, all differences between the volumes of tea drunk during two consecutive tea drinking sessions must be the same throughout the day. That is, the volumes of tea drunk during the day must form an arithmetic progression.
Every morning Zenyk wakes up and plans his tea drinking for that day. To do this, he chooses two integers \(a\) — the volume of tea to drink at 9 AM, and \(b\) — the volume of tea to drink at 9 PM.
Next, Zenyk calculates how much tea in total he will drink during the day if he follows all his rules? This daily procedure exhausts Zenyk.
Can you write a program to help him with the calculations?
Input
The single line contains two integers \(a\) and \(b\) — the volumes of tea to be drunk at 9 AM and 9 PM, respectively.
Output
If an integer sequence satisfying all the requirements does not
exist, output -1. Otherwise, output an integer — the total
volume of tea drunk during the day.
Constraints
\(1 \le a, b \le 10^9\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 1 13 | 91 |
| Input (stdin) | Output (stdout) |
|---|---|
| 2 17 | -1 |
Notes
\(1+2+3+4+5+6+7+8+9+10+11+12+13=91\).
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|