use strict; use warnings; my $verbose = 0; my ($h, $a) = split /[ \n]/, <>; my @enemy = ($h); my $count = 0; print $#enemy, "\n" if ($verbose); while ($#enemy >= 0) { if ($verbose) { print "enemy : "; for (@enemy) { print "$_, "; } print "\n"; } my $x = pop @enemy; my $y = int($x / $a); print "y = $y\n" if ($verbose); $count++; print "count = $count\n" if ($verbose); if ($y > 0) { push @enemy, $y; $count++; } } print "count = " if ($verbose); print $count, "\n";