· 8 years ago · Jan 24, 2018, 12:38 AM
1{-# OPTIONS_GHC -O2 -XNoMonomorphismRestriction #-}
2{-# LANGUAGE BangPatterns #-}
3{-(c) gorlum0 [at] gmail.com-}
4import Control.Monad (forM_)
5
6triangular = takeWhile (<=500) $ scanl1 (+) [1..]
7
8main = do
9 ls <- lines `fmap` getContents
10 let xs = map read ls
11 forM_ [x `elem` triangular | x <- xs] $
12 putStrLn . (\p -> if p then "YES" else "NO")