Project Euler #6: Sum square difference - Hacker Rank Program

Problem Statement
This problem is a programming version of Problem 6 from projecteuler.net
The sum of the squares of the first ten natural numbers is, 12+22+...+102=385. The square of the sum of the first ten natural numbers is, (1+2++10)2=552=3025. Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025385=2640.
Find the difference between the sum of the squares of the first N natural numbers and the square of the sum.
Input Format
First line contains T that denotes the number of test cases. This is followed by T lines, each containing an integer, N.

Output Format
Print the required answer for each test case.

Constraints 1T104 1N104
Sample Input
2
3
10
Sample Output
22
2640
 
MY SOLUTION:
 
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

    long int t;
    scanf("%ld",&t);
    while(t--)
     {
        long int n;
     scanf("%ld",&n);
        printf("%ld\n",(long int)pow(n*(n+1)/2,2)-(n*(n+1)*(2*n+1))/6);
       
    }
    return 0;
}
  

Convert resultset object to list of map

Convert the resultset object to list of map In some cases, while we doing API automation, we need to fetch the value from the DB and hav...