Page 1 of 1

10087 - The Tajmahal of ++Y2k

Posted: Tue Nov 26, 2002 5:56 am
by hesper
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():

[cpp]
int n, sum;
while(fin>>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);
else
evenArray(p, n);
for(int i=0; i<n*n; ++i)
p += add;
output(p, n, fout);
delete[] p;
}
else
fout<<"You can't be like Shahjahan!\n\n";
}[/cpp]

Posted: Sun Jul 13, 2003 11:22 am
by Whinii F.
Did you check out cases when n == 2 ?
In that case there is no configuration.

edit) Configurations can have 0 or negative integers.

Posted: Wed Jul 05, 2006 11:16 am
by rieo
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

Posted: Thu Dec 28, 2006 9:10 pm
by daveon
Yes, integers are enough for this problem.