Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module Main where
main :: IO ()
main = do
input <- getContents
let ((n, m), a, b, c) = readInput input
putStrLn $ unwords . map show . map (`mod` (10^9 + 7)) $ solve n m a b c
readInput :: String -> ((Int, Int), [Int], [Int], [Int])
readInput s =
let
( [n, m] : a : b : c : _) = map (map read) . map words . lines $ s
in
( (n, m) , a , b , c )
solve :: Int -> Int -> [Int] -> [Int] -> [Int] -> [Int]
solve n _ as bs cs = map product . zipWith (:) as
$ [ [ c | (b, c) <- zip bs cs, j `mod` b == 0] | j <- [1..n]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.