Skip to content

Instantly share code, notes, and snippets.

@Dobiasd
Created September 19, 2014 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dobiasd/6f1c6e582ca4ddc6dae4 to your computer and use it in GitHub Desktop.
Save Dobiasd/6f1c6e582ca4ddc6dae4 to your computer and use it in GitHub Desktop.
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