3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AtCoder #4: D - 表現の自由 ( Freedom of expression )

3
Posted at

Hackageのライブラリと多倍長を使ってシンプルにしてみる。

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
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?