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 Perl (v5.18.2) (judge verdict: Accepted)

#!/usr/bin/perl

my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);

@s = qw(1 3 5 7 11 13 17 19);

%a = ();

for(my $i=0;$i<=$#s;$i++){
  for(my $j=0;$j<=$#s;$j++){
    for(my $k=0;$k<=$#s;$k++){
      for(my $l=0;$l<=$#s;$l++){
        my $m = $s[$i] * $s[$j] * $s[$k] * $s[$l];
        next if $m > 199 or $m < 105;
        my %yk = ();
        for(my $x=0;$x<16;$x++){
          my $y = 1;
          $y *= $s[$i] if ($x & 1)!=0;
          $y *= $s[$j] if ($x & 2)!=0;
          $y *= $s[$k] if ($x & 4)!=0;
          $y *= $s[$l] if ($x & 8)!=0;
          $yk{$y} = 1;
        }
        my @nyk = keys %yk;
        next if $#nyk != 7;
        $a{$m} = 1;
      }
    }
  }
}

my $c = 0;
foreach my $k (sort keys %a){
  my $aa = $k - 0;
  $c++ if( $aa <= $n );
}

print "$c\n";

exit(0);