Skip to content

Instantly share code, notes, and snippets.

@tanakh
Created June 16, 2012 15:08
Show Gist options
  • Select an option

  • Save tanakh/2941576 to your computer and use it in GitHub Desktop.

Select an option

Save tanakh/2941576 to your computer and use it in GitHub Desktop.
AtCoder #4: D - 表現の自由 ( Freedom of expression ) ref: http://qiita.com/items/1b3d7d8e7f872f0ea637
import Control.Applicative
import Data.List
import Data.Numbers.Primes
main :: IO ()
main = do
[n, m] <- map read . words <$> getLine
let factors = group $ primeFactors $ abs n
ans = product (map (h m . genericLength) factors) * 2 ^ (m - 1)
print $ (ans :: Integer) `mod` 1000000007
h n r = comb (n + r - 1) r
comb _ 0 = 1
comb n m = comb (n-1) (m-1) * n `div` m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment