Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int f1(int n, int m) {
- if (m < 1 || n < 1)
- return 0;
- if (n == 1 && m == 1)
- return 0;
- if (m > n)
- return 1 + f1(m / 2, n) + f1(m - m / 2, n);
- return 1 + f1(m, n/2) + f1(m, n - n /2);
- }
- int main() {
- int m , n;
- FILE *f;
- f = fopen("in.txt", "r"); //deschidere in mod citire fiser
- fscanf(f, "%d%d", &n, &m);
- fclose(f);
- f = fopen("out.txt", "w");
- fprintf(f, "%d", f1(n, m));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment