use std::collections::HashSet; use proconio::input; fn main() { input! { K: usize, N: usize } let mut set = HashSet::new(); for x6 in (1_usize..).map(|x| x.pow(6)).take_while(|&x6| x6 <= N) { for y4 in (1_usize..).map(|y| y.pow(4)).take_while(|&y4| x6 + y4 <= N) { let n = x6 + y4; if n % K != 0 { continue; } let m = n / K; let z = f64::sqrt(m as f64) as usize; if z * z == m || (z + 1) * (z + 1) == m { set.insert(n); } } } println!("{}", set.len()); }