Created
June 16, 2012 15:08
-
-
Save tanakh/2941576 to your computer and use it in GitHub Desktop.
AtCoder #4: D - 表現の自由 ( Freedom of expression ) ref: http://qiita.com/items/1b3d7d8e7f872f0ea637
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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