11538 - Chess Queen

All about problems in Volume 115. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

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

11538 - Chess Queen

Post by azk84 » Sat Oct 25, 2008 6:56 pm

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

Post by Chimed » Sun Oct 26, 2008 1:00 am

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. :P

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

Re: 11538 - Chess Queen

Post by L I M O N » Sun Oct 26, 2008 3:42 pm

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

Post by azk84 » Sun Oct 26, 2008 5:20 pm

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

Post by Samiul » Sun Oct 26, 2008 6:28 pm

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

Post by SeregiB » Sun Oct 26, 2008 7:44 pm

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

Post by azk84 » Mon Oct 27, 2008 6:03 pm

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

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11538 - Chess Queen

Post by Obaida » Sat Apr 04, 2009 12:19 pm

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

Post by helloneo » Sat Apr 04, 2009 6:47 pm

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

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11538 - Chess Queen

Post by Obaida » Sun Apr 05, 2009 8:43 am

I solved the problem... n m sorry 4 d previous post.
That wasn't the real 1. :oops: :oops: :oops:
try_try_try_try_&&&_try@try.com
This may be the address of success.

Post Reply

Return to “Volume 115 (11500-11599)”