22/09/10 02:29:07.85 7pWsuKpo.net
>>751 Perl5
$ls = [17, 3, 3, 1, 6, 13, 11, 17, 2, 5, 7, 18, 16, 5, 8, 6, 5, 1, 11, 1];
$ss = [390, 240, 37, 396, 198, 99, 242, 53, 329, 202];
sub f {2 < @_ ? (f(@_[1..$#_]), map{[$_[0] * $_, $_[0], $_]} @_[1..$#_]) : ()}
@rs = sort{$$a[0] <=> $$b[0]} f @$ls;
for $aa (@$ss) {
@b = grep{$aa <= $$_[0]} @rs;
print @b ? "$aa:$b[0][1],$b[0][2]\n" : "$aa:error\n";
}
実行結果
$ perl 20_751.pl
390:error
240:17,16
37:3,13
396:error
198:18,11
99:17,6
242:17,16
53:3,18
329:error
202:13,16