what is wrong with my code?...i got WA...its the question from june cook-off

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define FOR(a,b) for(int f=a;f<=b-1;f++)//for b-a times iteration in forward
#define ROF(a,b) for(int r=a;r>b;r–)//for a-b times iteration in reverse
#define PB(n) push_back(n)
#define VI vector
#define P pair<int,int>
#define MP(a,b) make_pair(a,b)
#define LLI long long int
#define iss istringstream
#define F first
#define S second
using namespace std;

LLI ans;

int main(){

int t;

scanf("%d",&t);

for(int y=0;y<=t-1;y++){

	int n;

	scanf("%d",&n);

	ans=2*n*n*n*n-7*n*n*n+9*n*n-4*n;//simplified form for 2*n*(n-1)*(n-1)+n*(n-1)*(n-2)+2*n*(n-1)*(n-2)*(n-2)

	printf("%lld\n",ans);

}

}

Check this


[1]. This was your code. I made a slight change with the header file. You code is giving wrong answers for the test cases given in the link.

This is my code which gives the right output.[here][2]


This is your corrected 

3. You was using int. You were getting OVERFLOW. SO changed the data-type to unsigned long long int. Check this one now. Hope this will help you.:slight_smile:

Happy Coding

thanks for ur help bipin…the problem setter is definitely not worth being a problem setter at such a large scale event…he should have specified the max value of"n" more accurately…10000 is well within the limits to be accepted as int…thanks to you nevertheles

It is given in the constraints right? the range of N

//