A small q defines a sequence called a rollover sequence:
given integers n and m, satisfying n can be divisible by 2m. For a series of consecutive incrementing integers 1, 2, 3, 4 ..., every m-symbol is flipped once, the original symbol is '-';
For example n = 8, M = 2, the sequence is:-1,-2, +3, +4,-5,-6, +7, +8.
and n = 4, M = 1, the sequence is:-1, +2,-3, + 4.
Little Q Now I hope you can help him figure out the top N and how much.
Input Description:
Input consists of two integers n and m (2 <= N <= 109, 1 <= m), and satisfies n can be divisible by 2m.
Output Description:
Outputs an integer that represents the first n items and.
Input Example 1:
8 2
Output Example 1:
8
#include <iostream>usingnamespace std; int Main () { longlong m,n; // While (true) { cin>>n>>m; cout<< (m*m) *n/(2*m) <<Endl; // } return0;}
Flip the series "Tencent"