8 / 8
Jun 2012

include

include

int main()
{
int t,i;
scanf("%d",&t);
int arr[t];
long long int out;
for(i=0;i{ scanf("%d",&arr[i]);
out=floor(arr[i](arr[i]+2)((2*arr[i])+1)/8);
printf("%lld\n",out);
}
return 0;
}

please help !!!

  • created

    Jan '12
  • last reply

    Jun '12
  • 7

    replies

  • 167

    views

  • 3

    users

  • 1

    link

You need to use a datatype that will hold everything that you want to put in it. If your solution is long long, then your intermediate variables either need to be long long or you need to typecast them to long long.

i changed all variables to long long.. it worked.. but i couldn't understand it.. !! please explain ?

4 months later

Getting WA. Plz Help. I hav

used the standard formula. 
[code]
#include<stdio.h>
#include<math.h>
int main()
{
  int t;
long long tot,n;
  scanf("%d",&t);
  while(t--)
    {
      scanf("%lld",&n);
      tot=(long long)floor((n*(n+2)*(2*n+1))/8);
      printf("%lld\n",tot);
    }
  return 0;
}