Skip to content

Instantly share code, notes, and snippets.

@Nucleareal
Created December 12, 2013 14:04
Show Gist options
  • Save Nucleareal/7928413 to your computer and use it in GitHub Desktop.
Save Nucleareal/7928413 to your computer and use it in GitHub Desktop.
import Control.Applicative
import Data.Char
import Data.List
split :: (a -> Bool) -> [a] -> [[a]]
split p [] = []
split p xs = a : (split p $ dropWhile p $ b) where (a, b) = break p xs
splitBySpace :: String -> [String]
splitBySpace = split isSpace
getStair :: Integer -> Integer
getStair 0 = 1
getStair x = x * (getStair (x-1))
main :: IO()
main = do
rc <- getLine
xy <- getLine
dl <- getLine
let rci = map (\x -> read x :: Int) $ splitBySpace rc
let xyi = map (\x -> read x :: Int) $ splitBySpace xy
let dli = map (\x -> read x :: Int) $ splitBySpace dl
let vr = ((head rci) - (head xyi)) * ((head $ (tail rci)) - (head $ (tail xyi)))
let nn = (head xyi) * (head $ (tail xyi))
let mm = head dli
let un = getStair (fromIntegral(nn) :: Integer)
let sn = (getStair (fromIntegral(mm) :: Integer)) * (getStair (fromIntegral(nn - mm) :: Integer))
let ncm = un `div` sn
let ans = (ncm * (fromIntegral(vr) :: Integer)) `mod` (1000000007 :: Integer)
putStrLn $ show ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment