#include #define _M 1000001 #define min(a,b) (((a) > (b)) ? (b) : (a)) int main() { long int a, b, c, d, e, f, x1, x2, x3, x4, x; scanf("%li %li %li %li %li %li", &a, &b, &c, &d, &e, &f); while (a && b && c && d && e && f) { x1 = x2 = x3 = x4 = _M; x = 0; if (c*a <= e && b*d <= f) { x1 = 2; if (c*a == e) x1--; if (b*d == f) x1--; } if (c*a <= f && b*d <= e) { x2 = 2; if (c*a == f) x2--; if (b*d == e) x2--; } if (c*b <= e && a*d <= f) { x3 = 2; if (c*b == e) x3--; if (a*d == f) x3--; } if (c*b <= f && a*d <= e) { x4 = 2; if (c*b == f) x4--; if (a*d == e) x4--; } x = min(min(x1,x2),min(x3,x4)); if (x == _M) printf("The paper is too small.\n"); else { x += a*b-1; printf("The minimum number of cuts is %li.\n", x); } scanf("%li %li %li %li %li %li", &a, &b, &c, &d, &e, &f); } }