ITGUY29 - Editorial

Problem: Contest Page | CodeChef

DIFFICULTY:

EASY.

PROBLEM:

The chef was searching for his pen in the garage but he found his old machine with a display and some numbers on it. If some numbers entered then some different output occurs on the display. Chef wants to crack the algorithm that the machine is following.

Example to identify the pattern :

Input Output

9 36

5 10

1 0

2 1

Program:

#include<bits/stdc++.h> 
using namespace std; 

int main() 
{ 
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
   	int t;
   	cin>>t;
   	while(t--){
   	long long n;
   	cin>>n;
   	cout<<(n*(n-1))/2<<"\n";}
}