6 #include "Permutation.h"
16 if(
sizeof(mybitset)*8 < n)
17 throw std::overflow_error(
"Cannot store permutations in assigned type");
33 #define MY_CTZ(x) __builtin_ctzl(x)
34 #elif defined(USELONGLONG)
35 #define MY_CTZ(x) __builtin_ctzll(x)
45 auto w = (t + 1) | (((~t & -~t) - 1) >> (MY_CTZ(v) + 1));
91 unsigned long long result = 1;
93 for(
unsigned int i=1;i<=N;++i, --L)
95 auto g =
gcd(result, i);
99 if(result > std::numeric_limits<unsigned long long>::max() / t)
100 throw std::overflow_error(
"Overflow in CalcCombinations");
114 unsigned long long Permutation::gcd(
unsigned long long x,
unsigned long long y)
120 unsigned long long t = x % y;
134 return sizeof(mybitset)*8;
Permutation(unsigned int)
static unsigned long long CalcCombinations(unsigned int, unsigned int)
virtual mybitset get() const
static unsigned long long gcd(unsigned long long, unsigned long long)
static unsigned int getMax()