KPSUM - The Sum
One of your friends wrote numbers 1, 2, 3, ..., N on the sheet of paper. After that he placed signs + and - between every pair of adjacent digits alternately. Now he wants to find the value of the expression he has made. Help him.
For example, if N=12 then
+1 -2 +3 -4 +5 -6 +7 -8 +9 -1+0 -1+1 -1+2 = 5
Input
Each line contains one integer number N (1≤ N ≤ 1015). Last line contains 0 and shouldn't be processed. Number of lines in the input does not exceed 40.
Output
For every line in the input write the answer on a separate line.
Example
Input: 12 0 Output: 5
hide comments
abdou_93:
2013-11-18 02:57:49
@The new guy.. yes the ans for 10^15
|
|
Sandeep Pathry:
2013-05-31 06:31:38
Last edit: 2013-05-31 06:55:30 |
|
The new guy:
2012-01-09 12:12:43
Is the ans for 10^15 = 409090909090909 ?? Please help someone!! |
Added by: | Pavel Kuznetsov |
Date: | 2007-03-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | Vologda 2007 |