about summary refs log tree commit diff
path: root/usth/MATH2.3/4/sum-of-products.c
blob: 3fac72b17dc8f41e8c9d67af31484294cca3b611 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>

int main()
{
	size_t n, f;
	int b = 0;

	scanf("%zu %zu", &n, &f);
	for (size_t i = 0; !(i >> n); ++i) {
		if (!(f & 1 << i))
			continue;
		if (b)
			printf(" | ");
		b = 1;
		printf(i & 1 ? "x0" : "~x0");
		for (size_t j = 1; j < n; ++j)
			if (i & 1 << j)
				printf("&x%zu", j);
			else
				printf("&~x%zu", j);
	}
	putchar(10);

	return 0;
}