#3269. KPSUM - The Sum

KPSUM - The Sum

KPSUM - The Sum

题面翻译

题面

给你一个正整数 NN,依次把 11NN 写下来,在每两个数字之间交替的加上加减号,求这个表达式的值。例如,N=15N=15 时,表达式为 12+34+56+78+91+01+11+21+31+41+51-2+3-4+5-6+7-8+9-1+0-1+1-1+2-1+3-1+4-1+5

1N10151 \le N \le 10^{15}

题目描述

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

输入格式

Each line contains one integer number N (1≤ N ≤ 10 15 ^{15} ). Last line contains 0 and shouldn't be processed. Number of lines in the input does not exceed 40.

输出格式

For every line in the input write the answer on a separate line.

样例 #1

样例输入 #1

12
0

样例输出 #1

5