>>150 Perl5
use feature 'say';
for (<DATA>) {
chomp;
($W, $H, $a, $b) = split;
($x, $y, $t) = 0x3;
($w, $h) = ($W, $H);
do {
($w, $h) = (2*$w, 2*$h);
($tx, $ty) = ($w/$a, $h/$b);
$t = ($tx < $ty) ? $tx : $ty;
($x, $y) = ($a*$t, $b*$t);
} while ($x % (2*$W) != 0 or $y % (2*$H) != 0);
say "$_ -> $t";
}
__DATA__
2 4 1 1
3 4 2 1
4 5 2 4
1 2 10 5

実行結果
$ perl 11_150.pl
2 4 1 1 -> 8
3 4 2 1 -> 24
4 5 2 4 -> 20
1 2 10 5 -> 0.8