description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def solve(a, b, arr): s = set() vertical = 0 for x, y in arr: if x == a: vertical = 1 continue s.add((y - b) / (x - a)) return len(s) + vertical f = lambda: list(map(int, input().split())) n, x, y = f() res = solve(x, y, [f() for _ in range(n)]) print(res)
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def read_int(string): return tuple(map(int, string.split())) def slope(p1, p0): return (p1[1] - p0[1]) / (p1[0] - p0[0]) if p1[0] - p0[0] != 0 else float("inf") def min_lines(points, x0, y0): p0 = x0, y0 slope_dict = {} for p in points: s = slope(p, p0) if s in slope_dict: slope_dict[s] += 1 else: slope_dict[s] = 1 return len(slope_dict) def main(): n, x0, y0 = read_int(input()) points = [read_int(input()) for _ in range(n)] print(min_lines(points, x0, y0)) main()
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP VAR NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split(" ")) uniqueslopes = set() infinite = False for _ in range(n): stormx, stormy = map(int, input().split(" ")) if stormx - x != 0: uniqueslopes.add((stormy - y) / (stormx - x)) else: infinite = True if infinite: print(len(uniqueslopes) + 1) else: print(len(uniqueslopes))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
inp = input().split() arr = [[None for i in range(2)] for j in range(1000)] k = [0] * 1000 n = int(inp[0]) x0 = int(inp[1]) y0 = int(inp[2]) dx1 = 0 dy1 = 0 dx2 = 0 dy2 = 0 count = 0 for i in range(n): inp = input().split() arr[i][0] = int(inp[0]) arr[i][1] = int(inp[1]) for i in range(n): if k[i]: continue count = count + 1 dx1 = arr[i][0] - x0 dy1 = arr[i][1] - y0 for j in range(n): dx2 = arr[j][0] - x0 dy2 = arr[j][1] - y0 if dx2 * dy1 == dx1 * dy2: k[j] = 1 print(count)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = (int(x) for x in input().split()) dots = [tuple(float(x) for x in input().split()) for _ in range(n)] res = 0 is_horizontal, is_vertical = False, False dots_lines = [] for dot in dots: if dot[0] == x: if not is_vertical: is_vertical = True res += 1 continue if dot[1] == y: if not is_horizontal: is_horizontal = True res += 1 continue for line in dots_lines: if abs(dot[1] - line[0] * dot[0] - line[1]) <= 1e-10: break else: k = (y - dot[1]) / (x - dot[0]) b = -dot[0] * (y - dot[1]) / (x - dot[0]) + dot[1] dots_lines.append((k, b)) res += 1 print(res)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR IF VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR IF VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
from sys import stdin, stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int, input().split())) PI = float("inf") def slope(x, y): global s if x == x0: s.add(PI) else: s.add((y - y0) / (x - x0)) for i in range(1): n, x0, y0 = lst() s = set() for i in range(n): x, y = lst() slope(x, y) print(len(s))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def gcd(a, b): if a < 0: a = -a if b < 0: b = -b if a == 0: return b if b == 0: return a return gcd(b, a % b) def main(): n, x0, y0 = read() lines = set() for i in range(n): x, y = read() x -= x0 y -= y0 if x < 0 or x == 0 and y < 0: x, y = -x, -y g = gcd(x, y) x //= g y //= g lines.add((x, y)) return len(lines) def read(mode=2): inputs = input().strip() if mode == 0: return inputs if mode == 1: return inputs.split() if mode == 2: return list(map(int, inputs.split())) def write(s="\n"): if s is None: s = "" if isinstance(s, list): s = " ".join(map(str, s)) s = str(s) print(s, end="") write(main())
FUNC_DEF IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF STRING IF VAR NONE ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) hash = {} for i in range(n): a, b = map(int, input().split()) try: hash[(y - b) / (x - a)] except: if x - a != 0: hash[(y - b) / (x - a)] = 1 else: hash["y"] = 1 print(len(hash.keys()))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR STRING NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
import sys class Point: def __init__(self, x, y): self.x = x self.y = y def hash_point(point): x_val = (point.x + 10**4) * (2 * 10**4 + 1) y_val = point.y + 10**4 return x_val + y_val def cross_product(p1, p2): return p1.x * p2.y - p2.x * p1.y line = input().split(" ") n = int(line[0]) gun = Point(int(line[1]), int(line[2])) stps = {} for i in range(n): line = input().split(" ") x = int(line[0]) - gun.x y = int(line[1]) - gun.y point = Point(x, y) stps[hash_point(point)] = point count = 0 while stps: sweep = [] val = stps.popitem()[1] count += 1 for k in stps.keys(): if cross_product(val, stps[k]) == 0: sweep.append(k) for i in range(len(sweep)): del stps[sweep[i]] sys.stdout.write(str(count))
IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER NUMBER RETURN BIN_OP VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def mi(): return map(int, input().split()) n, x0, y0 = mi() s = set() for _ in range(n): x, y = mi() if x == x0: s.add(19191919) else: s.add((y - y0) / (x - x0)) print(len(s))
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) c = 0 vis = set() for i in range(n): x, y = map(int, input().split()) if x != x0: m = (y - y0) / (x - x0) if m not in vis: c = c + 1 vis.add(m) elif float("inf") not in vis: c = c + 1 vis.add(float("inf")) print(c)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
a, b, c = input().split() t = int(a) x, y = int(b), int(c) slopes = [] for i in range(t): a1, b1 = input().split() x1, y1 = int(a1), int(b1) if x1 - x != 0: slope = (y1 - y) / (x1 - x) else: slope = "slope" slopes.append(slope) print(len(set(slopes)))
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
input_arr = input().split() n = int(input_arr[0]) x0 = int(input_arr[1]) y0 = int(input_arr[2]) troopers = [] visited = [False] * n count = 0 for i in range(n): input_arr = input().split() troopers.append((int(input_arr[0]), int(input_arr[1]))) for i in range(n): if visited[i]: continue count += 1 dx1 = troopers[i][0] - x0 dy1 = troopers[i][1] - y0 for j in range(n): dx2 = troopers[j][0] - x0 dy2 = troopers[j][1] - y0 if dy1 * dx2 == dy2 * dx1: visited[j] = True print(count)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
[n, x0, y0] = [int(x) for x in input().split()] coordinates = [] for i in range(n): coordinates.append([int(x) for x in input().split()]) hit = [(False) for x in coordinates] num_shots = 0 for i in range(n): if not hit[i]: num_shots += 1 hit[i] = True for j in range(i + 1, n): if y0 - coordinates[i][1] == 0 and y0 - coordinates[j][1] == 0: hit[j] = True elif y0 - coordinates[i][1] == 0 or y0 - coordinates[j][1] == 0: continue elif (x0 - coordinates[i][0]) / (y0 - coordinates[i][1]) == ( x0 - coordinates[j][0] ) / (y0 - coordinates[j][1]): hit[j] = True print(num_shots)
ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER NUMBER BIN_OP VAR VAR VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
import sys LI = lambda: list(map(int, sys.stdin.readline().strip("\n").split())) MI = lambda: map(int, sys.stdin.readline().strip("\n").split()) SI = lambda: sys.stdin.readline().strip("\n") II = lambda: int(sys.stdin.readline().strip("\n")) n, x, y = MI() ms = {} for _ in range(n): a, b = MI() m = (y - b) / (x - a) if x - a else "inf" ms[m] = ms.get(m, 0) + 1 print(len(ms.keys()))
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR STRING ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = [int(it) for it in input().split()] arr = [] adj = False for i in range(n): x_, y_ = [int(it) for it in input().split()] arr.append([x_, y_]) if x_ == x: adj = True print( len(set([((it[1] - y) / (it[0] - x)) for it in arr if it[0] != x])) + (1 if adj else 0) )
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER VAR VAR NUMBER NUMBER
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def main(): n, x0, y0 = map(int, input().split(" ")) slopes = set() for i in range(n): x, y = map(int, input().split(" ")) if x != x0: slopes.add((y - y0) / (1.0 * (x - x0))) else: slopes.add("up") return len(slopes) print(main())
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING RETURN FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
contain = set() check = False count, temp1, temp2 = map(int, input().split(" ")) for _ in range(count): c1, c2 = map(int, input().split(" ")) if c1 - temp1 != 0: contain.add((c2 - temp2) / (c1 - temp1)) else: check = True if check: print(len(contain) + 1) else: print(len(contain))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, gun_x, gun_y = map(int, input().split()) shots = [] def find_slope(trooper_x, trooper_y): return float(trooper_y - gun_y) / float(trooper_x - gun_x) for _ in range(n): trooper_x, trooper_y = map(int, input().split()) if trooper_x == gun_x: shots.append("s") else: shots.append(find_slope(trooper_x, trooper_y)) print(len(set(shots)))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def slope(cx, cy, x, y): dx = cx - x if dx != 0: return (cy - y) / dx else: return float("inf") def CF514B(): N, cx, cy = list(map(int, input().split())) slopes = set() for i in range(N): x, y = list(map(int, input().split())) slopes.add(slope(cx, cy, x, y)) return len(slopes) result = CF514B() print(result)
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
normal_set = set([]) n, x, y = map(int, input().split()) m = [] for i in range(n): m.append(list(map(int, input().split()))) c = 0 for i in range(n): if m[i][0] - x == 0: c = 1 else: s = (m[i][1] - y) / (m[i][0] - x) normal_set.add(s) z = 0 for i in normal_set: z += 1 print(z + c)
ASSIGN VAR FUNC_CALL VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = [int(n) for n in input().split()] troopers = [] for i in range(n): troopers.append([int(n) for n in input().split()]) slope_to_laser = [] for coor in troopers: if coor[0] - x0 == 0: slope_to_laser.append("a") else: slope_to_laser.append((coor[1] - y0) / (coor[0] - x0)) slope_to_laser = set(slope_to_laser) print(len(slope_to_laser))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = [int(x) for x in input().split()] lista = [] for i in range(n): x1, x2 = [int(x) for x in input().split()] lista.append(x1) lista.append(x2) slope_list = [] for i in range(n): x1 = lista[i * 2] y1 = lista[i * 2 + 1] if x1 == x: slope = "xd" slope_list.append(slope) else: slope = (y1 - y) / (x1 - x) slope_list.append(slope) print(len(set(slope_list)))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def pendiente(hx, hy, x1, y1): if hx > x1: dx = hx - x1 dy = hy - y1 sl = dy / dx return sl elif hx < x1: dx = x1 - hx dy = y1 - hy sl = dy / dx return sl elif y1 == hy: return "x" n, x0, y0 = map(int, input().split(" ")) cT = [] dic = {} for x in range(n): cT.append(input()) for x in range(n): xtemp, ytemp = map(int, cT[x].split(" ")) sl = pendiente(x0, y0, xtemp, ytemp) if sl not in dic: dic.update({sl: 1}) else: dic[sl] += 1 print(len(dic))
FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR IF VAR VAR RETURN STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR DICT VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) vertical = 0 shot = set() for i in range(n): x, y = map(int, input().split()) if x == x0: vertical = 1 else: slope = (y - y0) / (x - x0) shot.add(slope) shot_num = len(shot) if vertical == 1: print(shot_num + 1) else: print(shot_num)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
I = lambda: map(int, input().split()) n, x, y = I() s = set() for _ in "0" * n: q, w = I() for e, r in s: if (w - r) * x + (e - q) * y + q * r - e * w == 0: break else: s.add((q, w)) print(len(s))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR BIN_OP STRING VAR ASSIGN VAR VAR FUNC_CALL VAR FOR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
import sys def pen(x0, y0, x1, y1): if float(x0 - x1) != 0: eme = float((y1 - y0) / (x1 - x0)) return eme else: return "inf" first_line = 0 ll = set([]) for i in sys.stdin: tp = i.split() if first_line == 0: first_line = 1 n_trooper = int(tp[0]) hansolo_position = int(tp[1]), int(tp[2]) else: ll.add(pen(int(tp[0]), int(tp[1]), hansolo_position[0], hansolo_position[1])) print(len(ll))
IMPORT FUNC_DEF IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR RETURN STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
import sys n, x0, y0 = [int(x) for x in sys.stdin.readline().split()] targets = [] for _ in range(n): x1, y1 = [int(x) for x in sys.stdin.readline().split()] notParallel = True for target in targets: x2 = target[0] y2 = target[1] c1 = (y0 - y1) * (x0 - x2) c2 = (y0 - y2) * (x0 - x1) if c1 == c2: notParallel = False if notParallel: targets.append((x1, y1)) print(len(targets))
IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) res = set() for i in range(n): a, b = map(int, input().split()) a -= x b -= y res.add("-" if a == 0 else b / a) print(len(res))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER STRING BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = list(map(int, input().split())) s = [] for i in range(n): s = s + [list(map(int, input().split()))] s = list(map(lambda x: (x[0] - x0) / (x[1] - y0) if x[1] - y0 != 0 else 3.14159265, s)) s.sort() r = 0 l = 3.141595 for i in s: if l != i: l = i r += 1 print(r)
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR LIST FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
l = input().split() l = list(map(int, l)) l1 = [] l2 = [] k = 0 j = 0 for x in range(l[0]): l1.append(input().split()) if l[1] - int(l1[-1][0]) == 0: j = 1 continue r = (l[2] - int(l1[-1][1])) / (l[1] - int(l1[-1][0])) for x in l2: if r == x: k = 1 if k == 0: l2.append(r) k = 0 if j == 1: print(len(l2) + 1) else: print(len(l2))
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
class Node: def __init__(self, x=None): self.value = x self.left = None self.right = None def __del__(self): del self class Set: root = None def __init__(self): self.root = None def __create_node__(self, x): return Node(x) def __add__(self, root, x): if root == None: return self.__create_node__(x) if root.value == None: root.value = x elif x < root.value: root.left = self.__add__(root.left, x) elif root.value < x: root.right = self.__add__(root.right, x) return root def __size__(self, root): if root == None: return 0 return self.__size__(root.left) + 1 + self.__size__(root.right) def __upper_bound__(self, root, x): if root == None: return None if x >= root.value: return self.__upper_bound__(root.right, x) left_bound = self.__upper_bound__(root.left, x) if left_bound == None: return root.value else: return min(left_bound, root.value) def __contains__(self, root, x): if root == None: return False if root.value == x: return True elif x < root.value: return self.__contains__(root.left, x) elif root.value < x: return self.__contains__(root.right, x) return None def __clear__(self, root): if root == None: return self.__clear__(root.left) self.__clear__(root.right) del root def add(self, x): self.root = self.__add__(self.root, x) def size(self): return self.__size__(self.root) def upper_bound(self, x): return self.__upper_bound__(self.root, x) def contains(self, x): return self.__contains__(self.root, x) def clear(self): self.root = self.__clear__(self.root) def gcd(a, b): while b != 0: r = a % b a = b b = r return a def main(): n, x, y = map(int, input().split()) s = Set() for i in range(n): u = tuple(map(int, input().split())) u = u[0] - x, u[1] - y v = u[0] // gcd(u[0], u[1]), u[1] // gcd(u[0], u[1]) if not s.contains(v) and not s.contains((-v[0], -v[1])): s.add(v) print(s.size()) main()
CLASS_DEF FUNC_DEF NONE ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE FUNC_DEF VAR CLASS_DEF ASSIGN VAR NONE FUNC_DEF ASSIGN VAR NONE FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF IF VAR NONE RETURN FUNC_CALL VAR VAR IF VAR NONE ASSIGN VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NONE RETURN NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR FUNC_DEF IF VAR NONE RETURN NONE IF VAR VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NONE RETURN VAR RETURN FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR NONE RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR RETURN FUNC_CALL VAR VAR VAR IF VAR VAR RETURN FUNC_CALL VAR VAR VAR RETURN NONE FUNC_DEF IF VAR NONE RETURN EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x1, y1 = map(int, input().split()) s = [] for _ in range(n): xi, yi = map(int, input().split()) s.append((xi, yi)) v = [False] * n ans = 0 for i in range(n): if not v[i]: ans += 1 x2, y2 = s[i] for j in range(n): x3, y3 = s[j] if (x1 - x2) * (y3 - y1) == (y1 - y2) * (x3 - x1): v[j] = True print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
import sys ep = 1e-06 def slope(x1, y1, x2, y2): try: return (float(y2) - float(y1)) / (float(x2) - float(x1)) except ZeroDivisionError: return None def yIntercept(slope, x, y): if slope != None: return y - slope * x def pointOnLine(m, c, x, y): if m == None: return x == c if y >= m * x + c - ep and y <= m * x + c + ep: return True return False def solution(allPoints, X, Y): lines = [] for point in allPoints: x, y = point killed = False for line in lines: m, c = line if pointOnLine(m, c, x, y): killed = True break if not killed: m = slope(X, Y, x, y) if m == None: c = x else: c = yIntercept(m, x, y) lines.append((m, c)) print(len(lines)) numPoints, originX, originY = input().split() numPoints = int(numPoints) originX = int(originX) originY = int(originY) allPoints = [] for i in range(numPoints): x, y = input().split() allPoints.append((int(x), int(y))) solution(allPoints, originX, originY)
IMPORT ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR RETURN NONE FUNC_DEF IF VAR NONE RETURN BIN_OP VAR BIN_OP VAR VAR FUNC_DEF IF VAR NONE RETURN VAR VAR IF VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NONE ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
l = set() n, x, y = map(int, input().split()) for i in range(n): a, b = map(int, input().split()) if a - x == 0: l.add(10**9 + 7) else: l.add((b - y) / (a - x)) print(len(l))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) s = [] count = 0 for i in range(n): a, b = map(int, input().split()) if a - x != 0: slope = (b - y) / (a - x) s.append(slope) else: count = 1 s = set(s) print(len(s) + count)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
import sys class Point: def __init__(self, x, y): self.x = float(x) self.y = float(y) n, gun_x, gun_y = map(int, sys.stdin.readline().split(" ")) gun_x = float(gun_x) gun_y = float(gun_y) points = [] for x in range(n): points.append(Point(*map(int, sys.stdin.readline().split(" ")))) d = {} for p in points: if gun_x == p.x: if "NaN" not in d: d["NaN"] = [p] else: d["NaN"].append(p) else: slope = (p.y - gun_y) / (p.x - gun_x) if slope not in d: d[slope] = [p] else: d[slope].append(p) print(len(d))
IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT FOR VAR VAR IF VAR VAR IF STRING VAR ASSIGN VAR STRING LIST VAR EXPR FUNC_CALL VAR STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def main(): troopers = [] no_dups = set() n, x0, y0 = map(int, input().split()) for a0 in range(n): x1, y1 = map(int, input().split()) c = x1, y1 if c not in no_dups: troopers.append(c) no_dups.add(c) count = 0 while troopers: current = troopers.pop() top = current[1] - y0 bot = current[0] - x0 troopers[:] = [ x for x in troopers if not (x[1] - y0) * bot == top * (x[0] - x0) ] count += 1 print(count) main()
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) d = {} ans = 0 for i in range(n): x1, y1 = map(int, input().split()) if x == x1: m = 100000000000 else: m = (y - y1) / (x - x1) c = y - m * x if m not in d: d[m] = [c] ans += 1 elif c not in d[m]: d[m].append(c) ans += 1 print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR LIST VAR VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
f = lambda: map(int, input().split()) n, a, b = f() l = [[*f()] for i in range(n)] k = [] for i in range(0, n): if l[i][0] != a: m = (l[i][1] - b) / (l[i][0] - a) else: m = "a" if m not in k: k.append(m) print(len(k))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR STRING IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = list(map(int, input().split())) m = [] for i in range(n): a, b = list(map(int, input().split())) s = (y - b) / (x - a) if x != a else "inf" m.append(s) m = set(m) print(len(m))
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def get_array(): return [int(el) for el in input().split()] def gcd(a, b, c=None): return (a if b == 0 else gcd(b, a % b)) if c is None else gcd(gcd(a, b), gcd(a, c)) def get_line_odds(point1, point2): A = point1[1] - point2[1] B = point2[0] - point1[0] C = point1[0] * point2[1] - point2[0] * point1[1] devider = gcd(A, B, C) return A / devider, B / devider, C / devider def shots(gun_coordinate, enemies): lines = set() count_shots = 0 for enemy in enemies: new_line = get_line_odds(gun_coordinate, enemy) if new_line not in lines: count_shots += 1 lines.add(new_line) return count_shots n, *gun_coordinate = get_array() enemies = [get_array() for _ in range(n)] print(shots(gun_coordinate, enemies))
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF NONE RETURN VAR NONE VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
from sys import stdin, stdout class Tail_Recursion_Optimization: def __init__(self, RECURSION_LIMIT, STACK_SIZE): setrecursionlimit(RECURSION_LIMIT) threading.stack_size(STACK_SIZE) return None class SOLVE: def solve(self): R = stdin.readline W = stdout.write n, X, Y = [int(x) for x in R().split()] x, y = {}, {} for i in range(n): x[i], y[i] = [int(x) for x in R().split()] min_shots = 0 for i in range(n): if x[i] != None: min_shots += 1 for j in range(i + 1, n): if x[j] != None: if (y[i] - Y) * (x[j] - X) == (y[j] - Y) * (x[i] - X): x[j] = None x[i] = None W("%d\n" % min_shots) return 0 def main(): s = SOLVE() s.solve() main()
CLASS_DEF FUNC_DEF EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN NONE CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR DICT DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NONE VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR NONE IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR NONE ASSIGN VAR VAR NONE EXPR FUNC_CALL VAR BIN_OP STRING VAR RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
my_list = {} def slope(x1, y1, x2, y2): m = (y2 - y1) / (x2 - x1) return m n, x, y = map(int, input().split()) for i in range(n): a, b = map(int, input().split()) if a - x: my_list[slope(x, y, a, b)] = 1 else: my_list[99999999999999] = 1 print(len(my_list))
ASSIGN VAR DICT FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def tinput(): return input().split() def rinput(): return map(int, tinput()) def rlinput(): return list(rinput()) n, x0, y0 = rinput() array = [] for _ in range(n): array.append(rlinput()) visited = [False] * n ans = 0 for i in range(n): if not visited[i]: ans += 1 x1, y1 = array[i] for j in range(i + 1, n): if not visited[j]: x, y = array[j] expr1 = (y - y0) * (x1 - x0) expr2 = (y1 - y0) * (x - x0) if expr1 == expr2: visited[j] = True print(ans)
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) k = [] for _ in range(n): a, b = map(int, input().split()) k.append((a, b)) hash = set() c = 0 for a, b in k: if a == x: hash.add("inf") else: m = (b - y) / (a - x) hash.add(m) print(len(hash))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) slopes = {} for i in range(n): x, y = map(int, input().split()) x -= x0 y -= y0 if x != 0: slopes[y / x] = True else: slopes["inf"] = True print(len(slopes))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR STRING NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = list(map(int, input().split())) b = [] c = [] d = [] for i in range(n): x, y = map(int, input().split()) if x - x0 != 0 and y - y0 != 0: t1 = (y - y0) / (x - x0) if t1 not in b: b.append(t1) elif y - y0 == 0: if y not in d: d.append(y) elif x not in c: c.append(x) print(len(b) + len(c) + len(d))
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def gcd(a, b): return gcd(b, a % b) if b else a a = [int(i) for i in input().split()] cnt = 0 s = [] for i in range(int(a[0])): b = [int(i) for i in input().split()] b[0] -= a[1] b[1] -= a[2] g = gcd(b[0], b[1]) b[0] /= g b[1] /= g if b not in s: s.append(b) print(len(s))
FUNC_DEF RETURN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) s = [] b = 0 for i in range(n): x1, y1 = map(int, input().split()) if x1 != x0: s.append((y1 - y0) / (x1 - x0)) else: b += 1 a = set(s) if b == 0: print(len(a)) else: print(len(a) + 1)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) A = [list(map(int, input().split())) for i in range(n)] S = set() B = [] for elem in A: i = 0 while i < len(B) and B[i][0] * elem[0] + B[i][1] * elem[1] + B[i][2] != 0: i += 1 if i == len(B): a = elem[1] - y b = x - elem[0] c = -(a * x + b * y) B.append((a, b, c)) print(len(B))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def slope(x0, y0, x, y): return (y - y0) / (x - x0) dict = {"equal": 0} inp = input() n, x0, y0 = inp.split(sep=" ") n = int(n) x0 = int(x0) y0 = int(y0) a = [] for i in range(n): inp = input() x, y = inp.split(" ") a.append((int(x), int(y))) for tpl in a: if tpl[0] == x0: dict["equal"] += 1 else: m = slope(x0, y0, tpl[0], tpl[1]) if m not in dict.keys(): dict.update({m: 1}) else: dict[m] += 1 dict = {it for it in dict if dict[it] != 0} print(len(dict))
FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR DICT STRING NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER VAR VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR EXPR FUNC_CALL VAR DICT VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = input().split() n = int(n) x = int(x) y = int(y) my_set = set() for i in range(n): x2, y2 = input().split() x2 = int(x2) y2 = int(y2) x2 = x2 - x y2 = y2 - y if x2 == 0: my_set.add("0") else: my_set.add(y2 / x2) print(len(my_set))
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) m, count = [], 0 for _ in range(n): x, y = map(int, input().split()) if x == x0: count = 1 else: m.append((y - y0) / (x - x0)) nodup = list(dict.fromkeys(m)) print(len(nodup) + count)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def belong(x1, x2, x3): if (x2[0] - x1[0]) * (x3[1] - x1[1]) == (x3[0] - x1[0]) * (x2[1] - x1[1]): return True return False pts = list() n, x, y = map(int, input().split()) point = [x, y] for i in range(0, n): pt = list(map(int, input().split())) pts.append(pt) count = 0 while len(pts) != 0: pt1 = pts[0] count += 1 pos = 0 while len(pts) != 0 and pos < len(pts): j = pts[pos] if belong(pt1, j, point): pts.remove(j) pos -= 1 pos += 1 print(count)
FUNC_DEF IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x1, y1 = map(int, input().split()) x = [] for i in range(n): x2, y2 = map(int, input().split()) if y2 - y1 == 0 and x2 - x1 == 0: pass elif y2 - y1 == 0: x.append(0) elif x2 - x1 == 0: x.append(-19999999) else: m = (y2 - y1) / (x2 - x1) x.append(m) x = list(set(x)) print(len(x))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) d = {} for i in range(n): a, b = map(int, input().split()) if y - b == 0: d["i"] = 0 else: d[(x - a) / (y - b)] = 0 print(len(d.keys()))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def calc_slope(p1, p2): dy = p2[1] - p1[1] dx = p2[0] - p1[0] if dx == 0: return "vertical" return dy / dx def calc_shots(origin, st): slopes = {} vertical = 0 for s in st: slope = calc_slope(origin, s) if slope in slopes.keys(): slopes[slope] += 1 else: slopes[slope] = 1 return len(slopes.keys()) def main(): num_st, o_x, o_y = input().strip().split(" ") num_st, o_x, o_y = int(num_st), int(o_x), int(o_y) origin = o_x, o_y st = [] for s in range(num_st): x, y = input().strip().split(" ") x, y = int(x), int(y) if not (x == origin[0] and y == origin[1]): st.append((x, y)) num_shots = calc_shots(origin, st) print(str(num_shots)) main()
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN STRING RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = [int(x) for x in input().split(" ")] def slope(x1, x2, y1, y2): if x2 - x1 == 0: return "inf" return (y2 - y1) / (x2 - x1) coords = [] slopes = {} for _ in range(n): x, y = [int(x) for x in input().split(" ")] coords.append((x, y)) for x, y in coords: m = slope(x0, x, y0, y) if m in slopes: slopes[m] += 1 else: slopes[m] = 1 print(len(slopes))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN STRING RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) ps = [list(map(int, input().split())) for i in range(n)] shut = [(False) for i in range(n)] ans = i = 0 for x, y in ps: if not shut[i]: ans += 1 j = 0 for x2, y2 in ps: if (x - x0) * (y2 - y0) == (x2 - x0) * (y - y0): shut[j] = True j += 1 i += 1 print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
d = {} n, x, y = map(int, input().split()) for i in range(n): a, b = map(int, input().split()) if a == x: d["3"] = True else: s = (b - y) / (a - x) d[s] = True print(len(d))
ASSIGN VAR DICT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) p = [] for i in range(n): x, y = map(int, input().split()) p.append([x, y]) used = [0] * n c = 1 for i in range(n): if used[i] != 0: continue used[i] = c for j in range(i + 1, n): if ( used[j] == 0 and (x0 - p[j][0]) * (p[i][1] - p[j][1]) - (p[i][0] - p[j][0]) * (y0 - p[j][1]) == 0 ): used[j] = c c += 1 print(max(used))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
[n, x0, y0] = list(map(int, input().split())) l = [] z = 0 for i in range(n): [x, y] = list(map(int, input().split())) x -= x0 y -= y0 if x == 0: z += 1 else: l.append(y / x) lset = set(l) if z > 0: z = 1 print(len(lset) + z)
ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def start(): n, x, y = [int(i) for i in input().split()] s = set({}) boo = False for i in range(n): nx, ny = [int(i) for i in input().split()] try: s.add((x - nx) / (y - ny)) except ZeroDivisionError: boo = True ans = len(s) if boo: ans += 1 print(ans) tc = 1 while tc: start() tc = tc - 1
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n = input() n = n.split(" ") cont = 0 dict = {} while cont < int(n[0]): g = input() g = g.split(" ") if int(n[2]) - int(g[1]) == 0: m = "8" else: m = (int(n[1]) - int(g[0])) / (int(n[2]) - int(g[1])) dict[m] = m cont += 1 cont2 = 0 for elemento in dict: cont2 += 1 print(cont2)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR DICT WHILE VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) unique_slopes = {"INF": 0} for i in range(n): x1, y1 = map(int, input().split()) if x1 - x == 0: unique_slopes["INF"] += 1 elif (y1 - y) / (x1 - x) not in unique_slopes.keys(): unique_slopes[(y1 - y) / (x1 - x)] = 1 else: unique_slopes[(y1 - y) / (x1 - x)] += 1 ans = len(unique_slopes.keys()) if unique_slopes["INF"] == 0: ans -= 1 print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT STRING NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER VAR STRING NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR STRING NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) cor = [] for i in range(n): cor.append([int(i) for i in input().split()]) ans = {} hor = False for i in range(len(cor)): xdiff = float(cor[i][0] - x) ydiff = float(cor[i][1] - y) if xdiff == 0: hor = True continue m = ydiff / xdiff ans[m] = 1 count = len(ans.keys()) if hor: count += 1 print(count)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def prin_pram(x, y): global A global B global C if A * x + B * y + C == 0: return 1 else: return 0 n, x0, y0 = map(int, input().split()) xyi = [list(map(int, input().split())) for i in range(n)] number = 0 i = 0 A = 0 B = 0 C = 0 z = 0 while number < n: i = 0 A = xyi[0][1] - y0 B = x0 - xyi[0][0] C = x0 * (y0 - xyi[0][1]) + y0 * (xyi[0][0] - x0) for j in range(n - number): temp = prin_pram(xyi[j][0], xyi[j][1]) if temp == 1: number += 1 else: xyi[i][0] = xyi[j][0] xyi[i][1] = xyi[j][1] i += 1 z += 1 print(z)
FUNC_DEF IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
maxx = 10**9 n, x0, y0 = map(int, input().split()) slopes = set() ans = 0 for _ in range(n): x, y = map(int, input().split()) if x == x0: slope = maxx else: slope = (y - y0) / (x - x0) if slope not in slopes: ans += 1 slopes.add(slope) print(ans)
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) d = {} for i in range(n): x, y = map(int, input().split()) if x - x0 == 0: d["a"] = d.get("a", 0) + 1 else: m = (y - y0) / (x - x0) d[m] = d.get(m, 0) + 1 print(len(d))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) d = {} for i in range(n): x, y = map(int, input().split()) d[x, y] = 1 ans = 0 for i in d: if d[i] == 1: x1 = i[0] y1 = i[1] if y0 - y1 == 0: m1 = float("inf") else: m1 = (x0 - x1) / (y0 - y1) for j in d: x2 = j[0] y2 = j[1] if y0 - y2 == 0: m2 = float("inf") else: m2 = (x0 - x2) / (y0 - y2) if m2 == m1: d[j] = 0 ans += 1 print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def det(x, y, x1, y1, x2, y2): return (x1 - x) * (y2 - y) - (y1 - y) * (x2 - x) t = [int(x) for x in input().split(" ")] points = {} visited = {} for i in range(0, t[0]): points[i] = [int(x) for x in input().split(" ")] visited[i] = False kill = t[0] i = 0 while i < t[0]: for j in range(i + 1, t[0]): if ( det(t[1], t[2], points[i][0], points[i][1], points[j][0], points[j][1]) == 0 and visited[j] == False and visited[i] == False ): visited[j] = True kill = kill - 1 visited[i] = True i = i + 1 print(kill)
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = [int(x) for x in input().split()] points = [] for i in range(n): x2, y2 = [int(x) for x in input().split()] points.append((x2, y2)) remaining_points = set() for i in points: remaining_points.add(i) def same_slope(point, point2): d_x = point[0] - x d_y = point[1] - y d_x2 = point2[0] - x d_y2 = point2[1] - y return d_x * d_y2 == d_y * d_x2 groups = [] for point in points: group = [] for point2 in remaining_points: if same_slope(point, point2): group.append(point2) for point2 in group: remaining_points.remove(point2) if len(group) > 0: groups.append(group) print(len(groups))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
a = [int(i) for i in input().split()] b = [] for i in range(a[0]): b.append([int(i) for i in input().split()]) b[i][0] -= a[1] b[i][1] -= a[2] b[i].append(0) k = 0 for i in range(a[0]): if not b[i][2]: k += 1 b[i][2] = k for j in range(i, a[0]): if not b[j][2]: if not b[j][1] or not b[j][0]: if ( b[j][1] == b[i][1] and b[j][1] == 0 or b[j][0] == b[i][0] and b[j][0] == 0 ): b[j][2] = k elif b[i][1] / b[j][1] == b[i][0] / b[j][0]: b[j][2] = k print(k)
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
class Node: def __init__(self, key=0, left=None, right=None): self.key = key self.left = left self.right = right def find(self, x): if self.key == x: return self if self.right and self.key < x: return self.right.find(x) if self.left and self.key > x: return self.left.find(x) return None def insert(self, x): if x < self.key: if self.left: self.left.insert(x) else: self.left = Node(x) elif x > self.key: if self.right: self.right.insert(x) else: self.right = Node(x) def find_min(self): cur = self while cur.left: cur = cur.left return cur def remove(self, x): if x < self.key: self.left = self.left.remove(x) elif x > self.key: self.right = self.right.remove(x) else: if self.left == None: return self.right elif root.right == None: return self.left temp = self.right.find_min() self.key = temp.key self.right = self.right.remove(temp.key) return self def size(self): size_left = 0 size_right = 0 if self.left: size_left = self.left.size() if self.right: size_right = self.right.size() return size_left + size_right + 1 class Set: def __init__(self): self.root = None def insert(self, x): if self.root: self.root.insert(x) else: self.root = Node(x) def remove(self, x): if self.root: self.root = self.root.remove(x) def find(self, x): if self.root: return self.root.find(x) return None def size(self): if self.root: return self.root.size() return 0 input_line = input().split() n = int(input_line[0]) x0 = float(input_line[1]) y0 = float(input_line[2]) bonus = 0 s = Set() for i in range(n): x, y = map(float, input().split()) if y == y0: bonus = 1 continue s.insert((x - x0) / (y - y0)) print(s.size() + bonus)
CLASS_DEF FUNC_DEF NUMBER NONE NONE ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR VAR RETURN VAR IF VAR VAR VAR RETURN FUNC_CALL VAR VAR IF VAR VAR VAR RETURN FUNC_CALL VAR VAR RETURN NONE FUNC_DEF IF VAR VAR IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR WHILE VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NONE RETURN VAR IF VAR NONE RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR IF VAR ASSIGN VAR FUNC_CALL VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR NONE FUNC_DEF IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR RETURN FUNC_CALL VAR VAR RETURN NONE FUNC_DEF IF VAR RETURN FUNC_CALL VAR RETURN NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
ar = set() inf = list(map(int, input().split())) a, b = inf[1], inf[2] n = inf[0] for i in range(n): inf = list(map(int, input().split())) x, y = inf[0] - a, inf[1] - b if x == 0: slope = 100000 else: slope = y / x ar.add(slope) print(len(ar))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = [int(x) for x in input().split()] count = 0 record = set() for i in range(0, n): a, b = [int(x) for x in input().split()] rise = y - b run = x - a if run == 0: slope = "e" else: slope = rise / run if slope not in record: record.add(slope) count += 1 print(count)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
MAX = 10**9 def getSlope(pt1, pt2): num = pt2[1] - pt1[1] den = pt2[0] - pt1[0] if den == 0: return MAX return num / den n, x0, y0 = map(int, input().split()) slopes = set() for i in range(n): x, y = map(int, input().split()) slopes.add(getSlope((x, y), (x0, y0))) print(len(slopes))
ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN VAR RETURN BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = (int(n) for n in input().split()) m = set() undefined = False for i in range(n): x, y = (int(n) for n in input().split()) dy, dx = y - y0, x - x0 if dx == 0: undefined = True else: m.add(dy / dx) print(len(m) + (1 if undefined else 0))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
a = list(map(int, input().split())) b = [] c = False for i in range(a[0]): d = list(map(int, input().split())) if d[0] == a[1]: c = True else: b += [d] print(c + len(set(map(lambda x: (x[1] - a[2]) / (x[0] - a[1]), b))))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR LIST VAR EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
class Node: def __init__(self, key=0): self.key = key self.left = None self.right = None def insertNode(root, x): global best if root == None: return Node(x) if x < root.key: root.left = insertNode(root.left, x) best = max(root.key - x, best) elif x > root.key: root.right = insertNode(root.right, x) return root n, x, y = map(int, input().split()) ar = set() flag = 0 for _ in range(n): a, b = map(int, input().split()) if a - x == 0: flag = 1 continue slope = (b - y) / (a - x) ar.add(slope) print(len(ar) + flag)
CLASS_DEF FUNC_DEF NUMBER ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE FUNC_DEF IF VAR NONE RETURN FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
N, x, y = list(map(int, input().split())) uniq = set() for i in range(N): x1, y1 = map(int, input().split()) if x - x1 == 0 and y - y1 != 0: uniq.add((x1, 0)) elif y - y1 == 0 and x - x1 != 0: uniq.add((0, y1)) else: uniq.add(((y - y1) / (x - x1), y - (y - y1) / (x - x1) * x)) print(len(uniq))
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
a, x, y = map(int, input().split()) x1, y1 = 0, 0 s = set() ans = 0 for _ in range(a): m, n = map(int, input().split()) if m - x == 0: x1 += 1 elif n - y == 0: y1 += 1 else: s.add((n - y) / (m - x)) if x1: ans += 1 if y1: ans += 1 ans += len(s) print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR NUMBER IF VAR VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def gcd(a, b): while b > 0: a, b = b, a % b return a n, x0, y0 = map(int, input().split()) slopes = dict() f = 0 for _ in range(0, n): x, y = map(int, input().split()) x, y = x - x0, y - y0 if y < 0: x *= -1 y *= -1 if y == 0: f = 1 else: g = gcd(max(abs(x), abs(y)), min(abs(x), abs(y))) x //= g y //= g slopes[x, y] = 1 print(len(slopes) + f)
FUNC_DEF WHILE VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) eqs = set() cnt = 0 for _ in range(n): x1, y1 = map(int, input().split()) if x1 - x0 == 0: if 10**9 not in eqs: cnt += 1 eqs.add(10**9) continue continue slope = (y1 - y0) / (x1 - x0) if slope not in eqs: cnt += 1 eqs.add(slope) print(cnt)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER IF BIN_OP NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def slope(x1, y1, x2, y2): if x1 == x2: return "inf" return (y2 - y1) / (x2 - x1) n, x1, y1 = map(int, input().split()) s = set() for _ in range(n): x2, y2 = map(int, input().split()) s.add(slope(x1, y1, x2, y2)) print(len(s))
FUNC_DEF IF VAR VAR RETURN STRING RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
t = input() temp = t.split() n = int(temp[0]) x0 = int(temp[1]) y0 = int(temp[2]) flag1 = 0 flag2 = 0 flag3 = 0 slopeList = [] for i in range(n): s = input() temp = s.split() x1 = int(temp[0]) y1 = int(temp[1]) if x1 - x0 != 0: slope = (y1 - y0) / (x1 - x0) else: slope = 0 if x1 == x0: flag1 = 1 elif y1 == y0: flag2 = 1 elif slope not in slopeList: slopeList.append(slope) flag3 += 1 print(flag1 + flag2 + flag3)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = [int(i) for i in input().split()] nodes = [] for _ in range(n): x, y = [int(i) for i in input().split()] nodes.append([x, y]) d = [] a = 0 for x, y in nodes: if [x, y] not in d: a += 1 d.append([x, y]) for i, j in nodes: if (i, j) == (x, y): continue elif (x - x0) * (j - y0) == (i - x0) * (y - y0): d.append([i, j]) print(a)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR IF LIST VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR VAR VAR IF VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
import sys input = sys.stdin.readline def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): s = input() return list(s[: len(s) - 1]) def invr(): return list(map(int, input().split())) visited = set() def solve(x0, y0, arr): count = 0 for a in arr: if x0 == a[0]: if "inf" not in visited: visited.add("inf") count += 1 elif (y0 - a[1]) / (x0 - a[0]) not in visited: visited.add((y0 - a[1]) / (x0 - a[0])) count += 1 return count nxy = inlt() arr = [] for i in range(nxy[0]): arr.append(inlt()) print(solve(nxy[1], nxy[2], arr))
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) coords = [list(map(int, input().split())) for _ in range(n)] points = lasers = 0 slopes = [] for i in range(n): if coords[i][0] == x: if "x" not in slopes: slopes += ["x"] elif (y - coords[i][1]) / (x - coords[i][0]) not in slopes: slopes += [(y - coords[i][1]) / (x - coords[i][0])] print(len(slopes))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR IF STRING VAR VAR LIST STRING IF BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER VAR VAR LIST BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = list(map(int, input().split())) tr = [] for i in range(n): tr.append(list(map(int, input().split()))) a = [] ans = 0 for i in range(n): if tr[i][1] - y0 == 0: ang = "inf" else: ang = (tr[i][0] - x0) / (tr[i][1] - y0) if not ang in a: a.append(ang) ans += 1 print(ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, k, m = map(int, input().split()) a = [] for i in range(n): a.append(list(map(int, input().split()))) l = 0 while a != []: i = 1 while i != len(a): if (a[0][0] - k) * (a[i][1] - m) == (a[i][0] - k) * (a[0][1] - m): a.pop(i) else: i += 1 a.pop(0) l += 1 print(l)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) c = [] for i in range(n): l = list(map(int, input().split())) c.append(l) slope = {} for i in c: if i[0] - x != 0: s = (i[1] - y) / (i[0] - x) else: s = 100000000000 slope[s] = 1 print(len(slope))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, xo, yo = [int(x) for x in input().split()] fl = 0 ans = [] for i in range(n): x, y = [int(k) for k in input().split()] xt = x - xo yt = y - yo if xt is 0: fl = 1 else: ans.append(yt / xt) print(int(len(list(set(ans)))) + int(fl))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = input().strip().split(" ") n, x, y = int(n), int(x), int(y) s = {} k = 0 for i in range(0, n): a, b = input().strip().split(" ") a, b = int(a), int(b) if x == a: p = 999999 q = 999999 else: p = (b - y) / (a - x) q = x * (y - b) / (a - x) - y if not p in s.keys(): w = {} w[q] = 1 s[p] = w k += 1 elif not q in s[p]: s[p][q] = 1 k += 1 print(k)
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR IF VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = map(int, input().split()) cord = [] for i in range(n): cord.append([int(x) for x in input().split()]) slopes = [] for co in cord: x1, y1 = co[0], co[1] if x1 - x0 != 0: slope = (y1 - y0) / (x1 - x0) slopes.append(slope) else: slopes.append("same") print(len(set(slopes)))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, a, b = map(int, input().split()) d = {} for i in range(n): x, y = map(int, input().split()) x -= a y -= b try: if x and y: d[y / x] += 1 elif not x: d["x0"] += 1 else: d["y0"] += 1 except: if x and y: d[y / x] = 1 elif not x: d["x0"] = 1 else: d["y0"] = 1 print(len(d))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR STRING NUMBER VAR STRING NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER IF VAR ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x, y = map(int, input().split()) count = 0 d = {} for i in range(n): p, q = map(int, input().split()) if q - y == 0: a = 10**5 else: a = (p - x) / (q - y) if a not in d.keys(): d[a] = 1 count += 1 else: d[a] += 1 print(count)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
n, x0, y0 = list(map(int, input().split())) storm = [] dic = {} for _ in range(n): x, y = list(map(int, input().split())) if y - y0 == 0: m = 0 elif x - x0 == 0: m = "undefined" else: m = (y - y0) / (x - x0) if m in dic: dic[m] += 1 else: dic[m] = 1 print(len(dic))
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x_0, y_0). Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers. The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location. -----Input----- The first line contains three integers n, x_0 ΠΈ y_0 (1 ≀ n ≀ 1000, - 10^4 ≀ x_0, y_0 ≀ 10^4) β€” the number of stormtroopers on the battle field and the coordinates of your gun. Next n lines contain two integers each x_{i}, y_{i} ( - 10^4 ≀ x_{i}, y_{i} ≀ 10^4) β€” the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point. -----Output----- Print a single integer β€” the minimum number of shots Han Solo needs to destroy all the stormtroopers. -----Examples----- Input 4 0 0 1 1 2 2 2 0 -1 -1 Output 2 Input 2 1 2 1 1 1 0 Output 1 -----Note----- Explanation to the first and second samples from the statement, respectively: [Image]
def find_shots(initial, storms): loc_map = {} for soldier in storms: deltay = soldier[1] - initial[1] deltax = soldier[0] - initial[0] if deltax == 0: slope = "nan" else: slope = deltay / deltax if slope not in loc_map: loc_map[slope] = 1 return len(loc_map.keys()) num_storms, x, y = list(map(int, input().split())) storms = [] for num in range(num_storms): a = input().split() q, w = [int(a[0]), int(a[1])] storms.append([q, w]) print(find_shots([x, y], storms))
FUNC_DEF ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR LIST VAR VAR VAR