Skip to content

Instantly share code, notes, and snippets.

@Zoha131
Last active March 23, 2017 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zoha131/8dd5577219d4a6f59d11442a9a48b68a to your computer and use it in GitHub Desktop.
Save Zoha131/8dd5577219d4a6f59d11442a9a48b68a to your computer and use it in GitHub Desktop.
Taking preparation for the take off contest.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main()
{
int t,i;
scanf("%d", &t);
for(i=0; i<t; i++)
{
long double n,j,first_intry,last_entry,differ,sum, sum2=0;
unsigned long long int result;
scanf("%llf", &n);
first_intry = 1;
last_entry = pow(n,2)- pow(n-1,2);
differ = 2;
//calculating sum with the help of formula of series.
sum = (n/2)*(first_intry+last_entry);
result = (unsigned long long int)sum%((unsigned long int)pow(10,9)+7);
//printing sum and result to debug the programe.
printf("%llf\t%llu\n",sum,result);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment