|
|||
SequenceConsider the infinite sequence: A=1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2,...which is formed by writing the vectors side by side for every . Peter’s task is to calculate the sum for any given positive integers . Let’s help him write the code! Input specificationThe first line contains the number of queries, . This is followed by lines, each containing two numbers for which the requested sum needs to be determined. The numbers on each line are separated by a space. Output specificationlines with answer for the queries. We can be certain that the answers will fit within a 64-bit signed integer. Constraints
Sample input 1
Sample output 1
Sample input 2
Sample output 2
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |