44 lines
1.2 KiB
Text
44 lines
1.2 KiB
Text
#include once "big_int/big_integer.bi"
|
|
|
|
Function DominoTilingCount(m As Integer, n As Integer) As Bigint
|
|
Dim As Double prod = 1.0
|
|
Dim As Integer jmax = m \ 2, kmax = n \ 2
|
|
|
|
For j As Integer = 1 To jmax
|
|
For k As Integer = 1 To kmax
|
|
Dim cj As Double = Cos(j * 4 * Atn(1) / (m + 1))
|
|
Dim ck As Double = Cos(k * 4 * Atn(1) / (n + 1))
|
|
Dim term As Double = 4 * cj * cj + 4 * ck * ck
|
|
prod *= term
|
|
Next
|
|
Next
|
|
|
|
' Round only at the end and convert to Bigint
|
|
Return Bigint(Clng(prod + 0.5))
|
|
End Function
|
|
|
|
Function FactBig(n As Integer) As Bigint
|
|
Dim As Bigint res = 1
|
|
For i As Integer = 2 To n
|
|
res *= i
|
|
Next
|
|
Return res
|
|
End Function
|
|
|
|
' Main program
|
|
Dim As Double t4 = Timer
|
|
|
|
Dim As BigInt arrang = DominoTilingCount(7, 8)
|
|
Dim As BigInt perms = FactBig(28)
|
|
Dim As BigInt flips = 2^28
|
|
|
|
Print "Arrangements ignoring values: "; arrang
|
|
Print "Permutations of 28 dominos: "; perms
|
|
Print "Permuted arrangements ignoring flipping dominos: "; arrang * perms
|
|
Print "Possible flip configurations: "; flips
|
|
Print "Possible permuted arrangements with flips: "; flips * arrang * perms
|
|
|
|
Dim As Double t5 = Timer
|
|
Print Using !"\nTook #.##### seconds."; t5-t4
|
|
|
|
Sleep
|