You are viewing a single comment's thread. Return to all comments →
Equivalently, do the same 1 and 2, check if lcm evenly divides gcd, then count the factors of gcd/lcm, otherwise 0.
main :: IO () countFac :: Int -> Int -> Int main = do getLine a_temp <- getLine let a = map read $ words a_temp :: [Int] b_temp <- getLine let b = map read $ words b_temp :: [Int] let l = foldl lcm (head a) (tail a) let g = foldl gcd (head b) (tail b) let s = g `div` l if s * l /= g then do print 0 return () else do print (countFac s 1) return () countFac n c | c > n `div` 2 = 1 | n `div` c * c == n = 1 + countFac n (c+1) | otherwise = countFac n (c+1)
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
Equivalently, do the same 1 and 2, check if lcm evenly divides gcd, then count the factors of gcd/lcm, otherwise 0.