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 C (GCC 5.4.1) (judge verdict: Accepted)

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/errno.h>

#define READ_BUF_SIZE 1024

static int
read_num (int *out, int max)
{
  char *p;
  char buf[READ_BUF_SIZE];
  int i = 0;
  char format[128];

  sprintf (format, "%%%d[^\n]%%*[^\n]", READ_BUF_SIZE);
  if (scanf (format, buf) == EOF)
    {
      printf ("EOF\n");
      fseek (stdin, 0L, SEEK_SET);
      return -1;
    }
  getchar ();

  for (p = strtok (buf, " "); p; p = strtok (NULL, " "))
    {
      char *endptr = NULL;
      long num = strtol (p, &endptr, 10);
      if (*endptr != '\0' || errno == ERANGE)
	continue;
      else
	out[i++] = num;
      if (i >= max)
	break;
    }
  return i;
}

int
main (int argc, char *argv[])
{
  int input[100];
  read_num (input, 1); 
  int i, j, cnt = 0;

  //printf ("%d\n", input[0]);
  for (i = 1; i <= input[0]; i++)
    {
      int surplus = 0;
      if (i % 2 == 0)
	continue;
      for (j = 1; j <= input[0]; j++)
      {
	if (i % j == 0)
	  surplus++;
      }
      if (surplus == 8)
	cnt++;
    }
  printf ("%d\n", cnt);
  return 0;
}