5
#define isqrt(a) ((a<0)?(-sqrt(-a)):sqrt(a))
6
#define max(a,b) (((a)>(b))?(a):(b))
7
#define min(a,b) (((a)<(b))?(a):(b))
8
#define rnd(i) ((int)((i) * (random() / (RAND_MAX + 1.0))))
9
#define calc_alloc(size,rounding) ((((size)/(rounding)) + (((size)%(rounding))?1:0))*(rounding))
11
#define lcm(x, y) ((x * y) / gcd(x, y))
12
#define lcm3(x, y, z) lcm(lcm(x, y), z)
14
#define SWAPij(index, i, j) { \
15
int tmp = *(index+i); *(index+i) = *(index+j); *(index+j) = tmp; \
17
#define SWAPi(index, properties, i) { \
18
int tmp1 = rnd(properties); \
19
SWAPij(index, i, tmp1); \
21
#define SWAP(index, properties, width) { \
22
int tmp1 = rnd(properties - width); \
23
int tmp2 = rnd(width); \
24
SWAPij(index, tmp2, width + tmp1); \
27
#define PRINT_MATRIX(fmt, MATRIX, width, n, m) \
30
for (i = 0; i < n; i++) { \
31
for (j = 0; j < m; j++) \
32
printf(fmt, MATRIX[i * width + j]); \
38
#define PRINT_MULTIMATRIX(num, fmt, MATRIX, width, n, m) \
41
for (i = 0; i < n; i++) { \
42
for (j = 0; j < m; j++) \
43
printf(fmt, MATRIX[4*(i * width + j) + num]); \
51
unsigned gcd(unsigned x, unsigned y);