9 procedure check(expr: boolean; msg: string);
\r
11 if (not expr) then begin
\r
12 writeln(erroutput, 'Error: ', msg);
\r
17 procedure checkBounds(n: int; low: int; hi: int; varName: string);
\r
19 check((low <= n) and (n <= hi), varName + ' is out of bounds [' + inttostr(low) + ', ' + inttostr(hi) + ']');
\r
24 a, b, f, answer: int;
\r
27 reset(input, 'business.in');
\r
28 rewrite(output, 'business.out');
\r
31 checkBounds(n, 1, 1000000, 'n');
\r
32 checkBounds(m, 1, 2000, 'm');
\r
33 answer := 2000000000;
\r
34 for i := 1 to m do begin
\r
36 checkBounds(u, 1, 1000, 'u');
\r
37 checkBounds(d, 1, 1000, 'd');
\r
38 a := (n * d) div (u + d) + 1;
\r
41 answer := min(answer, f);
\r