Skip to content

Instantly share code, notes, and snippets.

@gorlum0
Created August 23, 2011 13:44
Show Gist options
  • Save gorlum0/1165158 to your computer and use it in GitHub Desktop.
Save gorlum0/1165158 to your computer and use it in GitHub Desktop.
codeforces - 47 - A (hs)
{-# OPTIONS_GHC -O2 -XNoMonomorphismRestriction #-}
{-# LANGUAGE BangPatterns #-}
{-(c) gorlum0 [at] gmail.com-}
import Control.Monad (forM_)
triangular = takeWhile (<=500) $ scanl1 (+) [1..]
main = do
ls <- lines `fmap` getContents
let xs = map read ls
forM_ [x `elem` triangular | x <- xs] $
putStrLn . (\p -> if p then "YES" else "NO")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment