#include <sys/stat.h>
#include <iostream>
#include <iostream>
-using namespace std;
+////using namespace std;
#include <cstdlib>
#include <cmath>
#define mask31 0x0000001F
/** max function */
-#define max(x,y) ((x)>(y)?(x):(y))
+//#define max(x,y) ((x)>(y)?(x):(y))
/** min function */
-#define min(x,y) ((x)<(y)?(x):(y))
+//#define min(x,y) ((x)<(y)?(x):(y))
/** number of bits in a uint */
return __popcount_tab[(x >> 0) & 0xff] + __popcount_tab[(x >> 8) & 0xff]
+ __popcount_tab[(x >> 16) & 0xff] + __popcount_tab[(x >> 24) & 0xff];
}
+inline unsigned int
+fast_popcount(int x)
+{
+ uint m1 = 0x55555555;
+ uint m2 = 0x33333333;
+ uint m4 = 0x0f0f0f0f;
+ x -= (x >> 1) & m1;
+ x = (x & m2) + ((x >> 2) & m2);
+ x = (x + (x >> 4)) & m4;
+ x += x >> 8;
+ return (x + (x >> 16)) & 0x3f;
+}
+
+
/** Counts the number of 1s in the first 16 bits of x */
inline uint popcount16(int x){