Kattis Solution to Chanukah Challenge in CPP



#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int n;
cin >> n;
for (int i = 0; i <n; ++i)
{
int temp,j;
cin >> j >>temp;
int sum = 0;
for (int k = 2; k < temp+2; ++k)
{
sum+=k;
}
cout <<i+1<<" "<< sum<<"\n";
}
return 0;
}

Comments

Popular posts from this blog

Basketball One-on-One : Kattis Solution in C++

Kattis Solution to Reverse Binary in C++

Kattis Solution to Odd Man out In cpp