use std::collections::HashSet; use proconio::input; fn main() { input! { k: i64, n: i64, } let mut ans = 0; let mut set = HashSet::new(); for x in 1i64.. { let sumx = x.saturating_mul(x).saturating_mul(x).saturating_mul(x).saturating_mul(x).saturating_mul(x); if sumx > n { break; } for y in 1i64.. { let sum = sumx.saturating_add(y.saturating_mul(y).saturating_mul(y).saturating_mul(y)); if sum > n { break; } if sum % k == 0 { let s = sum / k; let mut ok = 1; let mut ng = 1e8 as i64; while ng - ok > 1 { let mid = (ok + ng) / 2; if mid * mid <= s { ok = mid; } else { ng = mid; } } if ok * ok == s { if !set.contains(&sum) { ans += 1; set.insert(sum); } } } } } println!("{}", ans); }