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: Accepted)

use std::collections::HashMap;

fn main() {
    let buf = io::read_string();
    let mut sc = io::Scanner::new(&buf);
    let n: usize = sc.read();
    let primes: Vec<usize> = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29];
    let mut a = Vec::new();
    for i in 0..primes.len() {
        for j in i+1..primes.len() {
            if primes[i] * primes[i] * primes[i] * primes[j] <= 200 {
               a.push(primes[i] * primes[i] * primes[i] * primes[j]);
            }
        }
    }
    for i in 0..primes.len() {
        for j in i+1..primes.len() {
            for k in j+1..primes.len() {
                if primes[i] * primes[j] * primes[k] <= 200 {
                    a.push(primes[i] * primes[j] * primes[k]);
                }
            }
        }
    }
    let m = a.into_iter().filter(|i| i % 2 != 0 && i <= &n).count();
    println!("{}", m);
}

#[allow(dead_code)]
mod io {
    use std;
    use std::io::Read;
    use std::str::{FromStr, SplitWhitespace};
    pub struct Scanner<'a> {
        pub iter: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.iter
                .next()
                .unwrap()
                .parse()
                .ok()
                .expect("parsing failed")
        }
        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}