Three Kinds of Sums
Time limit1sMemory limit256 MB
For each data set with N, print the sums of the first N positive integers, the first N odd integers, and the first N even integers.
- Level
Easy1 of 10
- Topics
- Math
- Solved
- No attempts yet
Problem
Given a positive integer , compute three sums: the sum of the first positive integers, the sum of the first odd integers, and the sum of the first even integers.
The input holds several such data sets. The data sets are independent, and every one is processed the same way.
Input
The first line contains the number of data sets . ()
Each of the next lines contains one data set: the data set number , a single space, and an integer . ()
Output
Print one line for each data set. Each line contains the data set number , a single space, then three integers , and separated by single spaces.
- is the sum of the first positive integers.
- is the sum of the first odd integers.
- is the sum of the first even integers.
The output lines follow the order of the data sets in the input.