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 Rust (1.15.1) (judge verdict: Wrong Answer)

use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn factorization(x: u32) -> Vec<u32> {
    let mut base = x;
    let mut div = 2;
    let mut v = Vec::new();

    let last = (base as f64).sqrt() as u32;
    while last >= div {
        if base % div == 0 {
            base /= div;
            v.push(div);
            continue;
        }
        div += 1;
    }
    v.push(base);
    v
}

fn group_by_same(v: Vec<u32>) -> Vec<Vec<u32>> {
    let mut groups = Vec::new();
    let mut group = Vec::new();
    group.push(v[0]);
    for i in 1..v.len() {
        if v[i - 1] != v[i] {
            groups.push(group);
            group = Vec::new();
        }
        group.push(v[i]);
    }
    if !group.is_empty() {
        groups.push(group);
    }
    groups
}

fn count_factor(x: u32) -> u32 {
    group_by_same(factorization(x))
        .into_iter()
        .map(|v| v.len() as u32 + 1)
        .fold(1, |st, x| st * x)
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.to::<u32>() + 1;
    println!(
        "{}",
        (1..n)
            .filter(|&x| x % 2 == 1)
            .filter(|&x| count_factor(x) == 8)
            .count()
    );
}