Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #define N 6
- int st[N] = { 1,1 };
- bool sol() {
- int fr[2] = {0, 0};
- for (int i = 0; i < N; i++) {
- fr[st[i]]++;
- }
- return fr[0] == 2 && fr[1] == 4;
- }
- void bktr(int k) {
- if (k == N - 1) {
- if (!sol()) {
- return;
- }
- for (int i = 0; i < N; i++) {
- printf("%d ", st[i]);
- }
- puts("");
- return;
- }
- for (int i = 0; i <= 1; i++) {
- st[k] = i;
- bktr(k + 1);
- }
- }
- int main(void) {
- st[N - 1] = 1;
- bktr(2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement