DefInt A-Z
Sub huitreines()
Dim q(8)
For i& = 0 To 40319
For j = 0 To 7: q(j) = j: Next: k& = i&
For j = 8 To 1 Step -1
SWAP q(j - 1), q(k& Mod j)
k& = k& \ j
Next
A = 0
b = 0
For j = 7 To 0 Step -1
v = 2 ^ (q(j) + j): If A And v Then Exit For
A = A + v
v = 2 ^ (q(j) - j + 7): If b And v Then Exit For
b = b + v
Next
If j < 0 Then
c = c + 1
Print c; ":";
For j = 0 To 7
Print Str$(q(j));
Next
Print
End If
Next
End Sub
Vu que j'ai pas trop carburé en maths jadisFor composite numbers n=pq, we can make a direct product of the p-queen and q-queen problems. That is, each queen position of the p-queen problem is regarded as a solution of the q-queen problem. We can change the roles of p and q. Thus for 35=5*7, we can generate 10*(40)^5 + 40*(10)^7 solutions.
To generate one solution for a general n, let the plane coordinated by i=0, ..., n-1 and j=0, ..., n-1.
Suppose n is even. For any k,
(2) If n is not 6k
j = (n/2 + 2i -1) mod n, for 0 <= i < n/2
j = (n/2 + 2i + 2) mod n, for n/2 <= i Example 3. n=8
Staple1600 à dit:Bonjour
Je vois que Pascal76 a joué le jeu
Je comprends pas trop de quels 10 posts tu parles.
Staple1600 à dit:Quel interet de livrer mon module aux autres forumeurs?
Merci pour le fair-play