-
-
Save Dobiasd/6f1c6e582ca4ddc6dae4 to your computer and use it in GitHub Desktop.
This file contains 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
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