#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU def gs(); gets.chomp; end def gi(); gets.to_i; end def gss(); gets.chomp.split; end def gis(); gss.map(&:to_i); end P, Q = gis N = gi d = (P > 0 && Q > 0) ? P.gcd(Q) : P + Q if P == 1 || Q == 1 || d == 1 p N exit end c = 0 N.times do x, y = gis.map(&:abs) if P == 0 && Q == 0 c += 1 if x == 0 && y == 0 next end c += 1 if x % d == 0 && y % d == 0 && x / d == y / d end p c