結果

問題 No.542 1円玉と5円玉
ユーザー motimoti
提出日時 2018-05-20 09:02:15
言語 Perl
(5.38.2)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 5,324 KB
実行使用メモリ 6,552 KB
最終ジャッジ日時 2023-09-10 23:54:18
合計ジャッジ時間 862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,908 KB
testcase_01 AC 5 ms
5,092 KB
testcase_02 AC 6 ms
4,972 KB
testcase_03 AC 6 ms
4,824 KB
testcase_04 AC 5 ms
4,848 KB
testcase_05 AC 6 ms
4,972 KB
testcase_06 AC 6 ms
5,048 KB
testcase_07 AC 6 ms
5,196 KB
testcase_08 AC 8 ms
5,356 KB
testcase_09 AC 9 ms
5,212 KB
testcase_10 AC 5 ms
4,868 KB
testcase_11 AC 5 ms
5,052 KB
testcase_12 AC 25 ms
6,552 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

use strict;
use warnings;

my %h;
my %memo;
sub dfs {
  my ($one, $five, $count) = @_;
  if (exists($memo{($one, $five)})) {
    return;
  }
  $memo{($one, $five)} = 1;
  if ($one > 0) {
    $h{$count + 1} = 1;
    dfs($one - 1, $five, $count + 1);
  }
  if ($five > 0) {
    $h{$count + 5} = 1;
    dfs($one, $five - 1, $count + 5);
  }
}

my ($x, $y) = split / /,<>; chomp$y;
dfs $x, $y, 0;
my @vs;
while (my ($k, $v) = each(%h)) {
  push @vs, $k;
}
for my $x (sort {$a <=> $b} @vs) {
  print $x . "\n";
}
0