View Code of Problem 2738

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;

int main(void){
	int a,n,k,count=0;
	scanf("%d",&n);
	while(n--){
		count++;
		int t=1,sum=0,j=1;
		scanf("%d",&k);
		for(int i=2;i<=k+1;i++){
			t+=i;
			a=j*t;
			sum+=a;
			j++;
		}
		printf("%d %d %d\n",count,k,sum);
	}
}

Double click to view unformatted code.


Back to problem 2738