Problem:
Score: 200 points

Problem Statement

The number 105 is quite special - it is odd but still it has eight divisors.
Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?

Constraints

N is an integer between 1 and 200 (inclusive).

Input

Input is given from Standard Input in the following format:

N

Output

Print the count.

Sample Input 1

105

Sample Output 1

1

Among the numbers between 1 and 105, the only number that is odd and has exactly eight divisors is 105.

Sample Input 2

7

Sample Output 2

0

1 has one divisor. 3, 5 and 7 are all prime and have two divisors. Thus, there is no number that satisfies the condition.

Solution in Haskell (GHC 7.10.3) (judge verdict: Accepted)

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- 約数列挙
divisor :: Int -> [Int]
divisor n = loop n 1
    where
        loop :: Int -> Int -> [Int]
        loop n i
            | n < i * i = []
            | n `mod` i == 0 && (i * i == n) = i : loop n (i+1)
            | n `mod` i == 0 && (i * i /= n) = i : (n `div` i) : loop n (i+1)
            | otherwise = loop n (i + 1)

main = do
  n <- readLn :: IO Int
  print $ length [() | i<-[1,3..n], let ds = divisor i, (length ds) == 8]