def licz(size, pictures): if(size[0] == 0) | (size[1] == 0): return 0 if len(pictures) == 0: print('error') return 0 c = int(size[0] / pictures[0]) r = int(size[1] / pictures[0]) if(c == 0) | (r == 0): return licz(size, pictures[1:]) return c * r + licz([size[0] - c * pictures[0], size[1]], pictures[1:]) + licz([c * pictures[0], size[1] - r * pictures[0]], pictures[1:]) w = list(map(int, input().split())) n = int(input()) r = list(map(int, input().split())) if (w[0] % r[0] != 0) | (w[1] % r[0] != 0): print(-1) exit() r.reverse() ile = licz(w, r) print(ile)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | def licz(size, pictures): if(size[0] == 0) | (size[1] == 0): return 0 if len(pictures) == 0: print('error') return 0 c = int(size[0] / pictures[0]) r = int(size[1] / pictures[0]) if(c == 0) | (r == 0): return licz(size, pictures[1:]) return c * r + licz([size[0] - c * pictures[0], size[1]], pictures[1:]) + licz([c * pictures[0], size[1] - r * pictures[0]], pictures[1:]) w = list(map(int, input().split())) n = int(input()) r = list(map(int, input().split())) if (w[0] % r[0] != 0) | (w[1] % r[0] != 0): print(-1) exit() r.reverse() ile = licz(w, r) print(ile) |