sub f{my($x,$i,$n)=@_; if($n==1){ ++$% }else{ for($i..$#d){ last if$d[$_]**$n>$x; if($x%$d[$_]==0){ f($x/$d[$_],$_,$n-1) } } } $% } ($N,$X)=glob<>; $X%$_||push@d,$_ for 2..sqrt++$X; push@d,map$X/$_,reverse@d[0..$#_-($_[-1]**2==$X)]; print f($X,0,$N)