Article View: gnu.chess
Article #4251Re: a beginer want to know ......
From: Marcel van Kervinck
Date: Mon, 23 Oct 1995 00:00
Date: Mon, 23 Oct 1995 00:00
21 lines
1045 bytes
1045 bytes
zhuhail@vax.sbu.ac.uk wrote:
> I just want to know how difficult following problem is:
> put 8 queens in the chess board without attach each orther.
> How many solutions it may have.
/*
queens.c by Marcel van Kervinck <marcelk@stack.urc.tue.nl>
solves the problem of placing n queens on
an n*n board without attacking eachother
*/
t(a,b,c){int d=0,e=a&~b&~c,f=1;if(a)for(f=0;d=(e-=d)&-e;f+=t(a-d,(b+d)*2,(
c+d)/2));return f;}main(q){scanf("%d",&q);printf("%d\n",t(~(~0<<q),0,0));}
Regards,
Marcel
-- _ _
_| |_|_|
|_ |_ Marcel van Kervinck
|_| buex95a@urc.tue.nl
Technical Details
Message-ID:
<46gtua$ko2@tuegate.tue.nl>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<1995Oct17.194728.1@vax.sbu.ac.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d71d,57b3ee363d233a99 X-Google-Attributes: gid10d71d,public From: buex95a@asterix (Marcel van Kervinck) Subject: Re: a beginer want to know ...... Date: 1995/10/23 Message-ID: <46gtua$ko2@tuegate.tue.nl> X-Deja-AN: 117997087 references: <1995Oct17.194728.1@vax.sbu.ac.uk> organization: Eindhoven University of Technology, The Netherlands newsgroups: gnu.chess