use std::cmp::*; use std::collections::*; use std::fmt::Debug; use std::io::{stdin, Read}; use std::str::FromStr; #[derive(Eq, PartialEq, Clone, Debug)] pub struct Rev(pub T); impl PartialOrd for Rev { fn partial_cmp(&self, other: &Rev) -> Option { other.0.partial_cmp(&self.0) } } impl Ord for Rev { fn cmp(&self, other: &Rev) -> Ordering { other.0.cmp(&self.0) } } fn read() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } macro_rules! read { (($($t:tt),*)) => { ( $(read!($t)),* ) }; ([[$t:tt; $len1:expr]; $len2:expr]) => { (0..$len2).map(|_| read!([$t; $len1])).collect::>() }; ([$t:tt; $len:expr]) => { (0..$len).map(|_| read!($t)).collect::>() }; (chars) => { read!(String).chars().collect::>() }; (usize1) => { read!(usize) - 1 }; ($t:ty) => {{ let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse::<$t>().unwrap() }}; } macro_rules! input { (mut $name:ident: $t:tt, $($r:tt)*) => { let mut $name = read!($t); $(println!("{}", stringify!($r));)* input!($($r)*); }; (mut $name:ident: $t:tt) => { let mut $name = read!($t); }; ($name:ident: $t:tt, $($r:tt)*) => { let $name = read!($t); input!($($r)*); }; ($name:ident: $t:tt) => { let $name = read!($t); }; } pub fn prime_factorize(_n: &u64) -> Vec<(u64, usize)> { let mut n = _n.clone(); let mut res = Vec::new(); for p in 2..((*_n as f64).sqrt() as u64) + 1 { if n % p != 0 { continue; } let mut num = 0; while n % p == 0 { num += 1; n /= p; } res.push((p, num)); } if n != 1 { res.push((n, 1)); } return res; } fn main() { input!(n: u64, k: u64, m: u64); let factors = prime_factorize(&n); struct SolveEnv { factors: Vec<(u64, usize)>, k: u64, m: u64, } let env = SolveEnv { factors: factors, k: k, m: m, }; fn solve(env: &SolveEnv, i: usize, num: u64) -> u64 { if i == env.factors.len() { if num <= env.m { return 1; } else { return 0; } } let mut res = 0; for count in 0..(env.factors[i].1 * env.k as usize + 1) { let next = num * env.factors[i].0.pow(count as u32); if next <= env.m { res += solve(env, i + 1, next); } else { break; } } return res; } println!("{}", solve(&env, 0, 1)); }