Sort 12 Discussions, By:
Please Login in order to post a comment
it is really easy to use the bigint structure (F#)
What does this part mean But instead of printing complete answer you have to print answer modulo 109+7.
But instead of printing complete answer you have to print answer modulo 109+7.
Also the explaination of test case 2 is not related to how actually the method should be solved, there would be no way of discovering such pattern of 2^a and 3^a
The task is not about Functional Programming. It's a pure Number theory.
main :: IO ()
main = f <$> readN <*> readN >>= print
f :: Integer -> Integer -> Integer
f = ((`mod` k) .) . gcd
k :: Integer
k = 1000000007
readN :: IO Integer
readN = getLine >> product . map read . words <$> getLine
One-liner in Haskell (no focus on performance though):
solve :: [Integer] -> [Integer] -> Integer
solve ns ms = flip mod (10^9 + 7)
$ gcd (product ns) (product ms)