10087 - The Tajmahal of ++Y2k

All about problems in Volume 100. 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
New poster
Posts: 2
Joined: Sat Nov 23, 2002 9:08 am

10087 - The Tajmahal of ++Y2k

Post by hesper » Tue Nov 26, 2002 5:56 am

Please, I've just tried to submit 10087 for several times, and ---- WA. I'm afraid I didn't understand the problem well, for:
1. Whether negative and 0 are allowed to construct the magic square?
2. Are there any special test numbers I didn't consider well?

I have two functions to construct the square, and they are certainly right. The following is my main():

int n, sum;
int magic_const = n*(n*n+1)/2;
if( (sum - magic_const)%n == 0 && sum - magic_const >= 0 )
int add = (sum - magic_const)/n;
int *p=new int[n*n];
if(n%2 != 0)
oddArray(p, n);
evenArray(p, n);
for(int i=0; i<n*n; ++i)
p += add;
output(p, n, fout);
delete[] p;
fout<<"You can't be like Shahjahan!\n\n";

Whinii F.
Experienced poster
Posts: 151
Joined: Wed Aug 21, 2002 12:07 am
Location: Seoul, Korea

Post by Whinii F. » Sun Jul 13, 2003 11:22 am

Did you check out cases when n == 2 ?
In that case there is no configuration.

edit) Configurations can have 0 or negative integers.
JongMan @ Yonsei

New poster
Posts: 9
Joined: Tue Jul 04, 2006 10:46 am
Location: Taiwain

Post by rieo » Wed Jul 05, 2006 11:16 am

i try to solve this problem but get WA, i use formula to get the magic array for 3 types: odd, 4n, 4n+2 and seems good..

is there any critical input i lose?

L=2 print can't

L and S can only use %d?

and every element i printed use %10d ?

Can any ACer reply? thx

Experienced poster
Posts: 229
Joined: Tue Aug 31, 2004 2:41 am

Post by daveon » Thu Dec 28, 2006 9:10 pm

Yes, integers are enough for this problem.

Post Reply

Return to “Volume 100 (10000-10099)”