## 11538 - Chess Queen

Moderator: Board moderators

azk84
New poster
Posts: 14
Joined: Sat Sep 13, 2008 7:50 pm
Location: Tehran
Contact:

### 11538 - Chess Queen

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

Chimed
New poster
Posts: 12
Joined: Mon Oct 20, 2008 10:37 am

### Re: 11538 - Chess Queen

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.

L I M O N
Learning poster
Posts: 58
Joined: Wed Dec 31, 2003 8:43 am
Contact:

### Re: 11538 - Chess Queen

visit: http://www.youngprogrammer.com to get test data

azk84
New poster
Posts: 14
Joined: Sat Sep 13, 2008 7:50 pm
Location: Tehran
Contact:

### Re: 11538 - Chess Queen

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:

Code: Select all

``````AC...
``````
Last edited by azk84 on Mon Oct 27, 2008 6:04 pm, edited 1 time in total.

Samiul
New poster
Posts: 36
Joined: Thu Dec 13, 2007 3:01 pm

### Re: 11538 - Chess Queen

You are having integer overflow. Check for n = 1000000 and m = 1000000.

SeregiB
New poster
Posts: 3
Joined: Wed Aug 06, 2008 9:24 pm
Location: Hungary, Debrecen
Contact:

### Re: 11538 - Chess Queen

Hello!

Use unsigned long long int.
Sorry for my poor english

azk84
New poster
Posts: 14
Joined: Sat Sep 13, 2008 7:50 pm
Location: Tehran
Contact:

### Re: 11538 - Chess Queen

Thank you Samiul and SeregiB for your help! I finally got AC after 8 tries

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11538 - Chess Queen

Why i got wa so many times?

Code: Select all

``removed``
Last edited by Obaida on Sun Apr 05, 2009 8:42 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

### Re: 11538 - Chess Queen

Does your program print the sample output correctly..??

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am