Programming contests

ACM ICPC programozó csapatverseny, házi forduló, 2016. október 15.

October 15, 2016, 10:00 AM – October 15, 2016, 3:00 PM

Sum Kind Of Problem

For this problem, you will compute various running sums of values for positive integers.

Input Specification

The first line of the input contains a single integer P (1 ≤ P ≤ 10 000), which is the number of data sets that follow. Each data set should be processed identically and independently.

Each data set consists of a single line of input. It contains the data set number K, followed by an integer N (1 ≤ N ≤ 10 000).

Output Specification

For each data set, there is one line of output. The single output line consists of the data set number K, followed by a single space, followed by three space-separated integers S1, S2, and S3, such that:

S1 = The sum of the first N positive integers.

S2 = The sum of the first N odd integers.

S3 = The sum of the first N even integers.

Sample Input

  1. 3
  2. 1 1
  3. 2 10
  4. 3 1001
download as text file

Output for Sample Input

  1. 1 1 1 2
  2. 2 55 100 110
  3. 3 501501 1002001 1003002
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024