fn divisors(n: i64) -> Vec { let mut d = Vec::new(); for i in 1..=(f64::sqrt(n as f64) + 1e-18) as i64 { if n % i == 0 { d.push(i); if i != n / i { d.push(n / i); } } } d.sort(); d } fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let p: i64 = itr.next().unwrap().parse().unwrap(); let q: i64 = itr.next().unwrap().parse().unwrap(); let mut ans = Vec::new(); for x in divisors(q * q) { let y = q * q / x; if (x + q) % p ==0 && (y + q) % p == 0 { ans.push(((x + q) / p, (y + q) / p)); } } ans.sort_unstable(); println!("{}", ans.len()); if !ans.is_empty(){ for i in ans.iter() { println!("{} {}", i.0, i.1); } } }