Page 1 of 1
11538 - Chess Queen
Posted: Sat Oct 25, 2008 6:56 pm
by azk84
I solved this problem in 2 ways, but I got 7 WA's in contest. Can anybody give some test cases plz? I really have no idea why I'm getting WA

Re: 11538 - Chess Queen
Posted: Sun Oct 26, 2008 1:00 am
by Chimed
It is easy when N=1. You can find a formula.
Then you can find all possibilities horizontal and verticals.
After that you need to calculate diagonals (2 kind). The hardest thing might be the case N!=M.
Here is one formula you may use 1+4+9+...+n*n=n(n+1)(2n+1)/6
Good luck.

Re: 11538 - Chess Queen
Posted: Sun Oct 26, 2008 3:42 pm
by L I M O N
Re: 11538 - Chess Queen
Posted: Sun Oct 26, 2008 5:20 pm
by azk84
Thank you for your help Chimed. I used a formula to calculate result, and tested the program with LIMON's test data and it gives correct answer, but I'm still getting WA

. This is my code:
Re: 11538 - Chess Queen
Posted: Sun Oct 26, 2008 6:28 pm
by Samiul
You are having integer overflow. Check for n = 1000000 and m = 1000000.
Re: 11538 - Chess Queen
Posted: Sun Oct 26, 2008 7:44 pm
by SeregiB
Hello!
Use unsigned long long int.

Re: 11538 - Chess Queen
Posted: Mon Oct 27, 2008 6:03 pm
by azk84
Thank you Samiul and SeregiB for your help!

I finally got AC after 8 tries

Re: 11538 - Chess Queen
Posted: Sat Apr 04, 2009 12:19 pm
by Obaida
Why i got wa so many times?
Re: 11538 - Chess Queen
Posted: Sat Apr 04, 2009 6:47 pm
by helloneo
Does your program print the sample output correctly..??
Re: 11538 - Chess Queen
Posted: Sun Apr 05, 2009 8:43 am
by Obaida
I solved the problem... n m sorry 4 d previous post.
That wasn't the real 1.
