• [1610] Glamor Sequence

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • you have a sequence +1, +2, +3, ... +m, -(m + 1), -(m + 2), ..., -(2m), (2m + 1), (2m + 2), ..., (3m), .....
    and you need calculator sum of the first n items.
  • 输入
  • For each test case, there is a line contains two integers n and m, (1 <= m <= n <= 1000000000).
  • 输出
  • For each test case, print sum of the first n items.
  • 样例输入
  • 8 2
    10 3
  • 样例输出
  • -8
    5
  • 提示
  • For the first sample, the sequence is 1, 2, -3, -4, 5, 6, -7, -8, so the answer is -8.
    For the second sample, the sequence is 1, 2, 3, -4, -5, -6, 7, 8, 9, -10, so the answer is 5.
  • 来源
  • 本站或者转载
  • 操作

显示春菜