description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
A Maze is given as n*n matrix of blocks where source block is the upper left most block i.e., matrix[0][0] and destination block is lower rightmost block i.e., matrix[n-1][n-1]. A rat starts from source and has to reach the destination. The rat can move in only two directions: first forward if possible or down. If multiple solutions exist, the shortest earliest hop will be accepted. For the same hop distance at any point, forward will be preferred over downward. In the maze matrix, 0 means the block is the dead end and non-zero number means the block can be used in the path from source to destination. The non-zero value of mat[i][j] indicates number of maximum jumps rat can make from cell mat[i][j]. In this variation, Rat is allowed to jump multiple steps at a time instead of 1. Find a matrix which describes the position the rat to reach at the destination.
Example:
Input: {{2,1,0,0},{3,0,0,1},{0,1,0,1},
{0,0,0,1}}
Output: {{1,0,0,0},{1,0,0,1},{0,0,0,1},
{0,0,0,1}}
Explanation: Rat started with matrix[0][0] and
can jump up to 2 steps right/down. First check
matrix[0][1] as it is 1, next check
matrix[0][2] ,this won't lead to the solution.
Then check matrix[1][0], as this is 3(non-zero)
,so we can make 3 jumps to reach matrix[1][3].
From matrix[1][3] we can move downwards taking
1 jump each time to reach destination at
matrix[3][3].
Example 2:
Input: {{2,1,0,0},{2,0,0,1},{0,1,0,1},
{0,0,0,1}}
Output: {{-1}}
Explanation: As no path exists so, -1.
Your Task:
You don't need to read or print anyhting, Your task is to complete the function ShortestDistance() which takes the matrix as input parameter and returns a matrix of size n if path exists otherwise returns a matrix of 1x1 which contains -1. In output matrix, 1 at (i, j) represents the cell is taken into the path otherwise 0 if any path exists.
Expected Time Complexity: O(n*n*k) where k is max(matrix[i][j])
Expected Space Complexity: O(1)
Constraints:
1 <= n <= 50
1 <= matrix[i][j] <= 20 | class Solution:
def ShortestDistance(self, matrix):
n = len(matrix)
sol = [([0] * n) for i in range(n)]
def safe(i, j):
if i < 0 or i >= n or j < 0 or j >= n:
return False
return True
def helper(i, j, matrix, sol):
if i == n - 1 and j == n - 1:
sol[i][j] = 1
return True
if safe(i, j):
sol[i][j] = 1
for x in range(1, matrix[i][j] + 1):
if helper(i, x + j, matrix, sol):
return True
if helper(x + i, j, matrix, sol):
return True
sol[i][j] = 0
return False
return False
if helper(0, 0, matrix, sol):
if sol[n - 1][n - 1] == 1:
return sol
else:
return [[-1]] | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER VAR VAR VAR NUMBER VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR RETURN NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER IF FUNC_CALL VAR NUMBER NUMBER VAR VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN LIST LIST NUMBER |
You like the card board game "Set". Each card contains $k$ features, each of which is equal to a value from the set $\{0, 1, 2\}$. The deck contains all possible variants of cards, that is, there are $3^k$ different cards in total.
A feature for three cards is called good if it is the same for these cards or pairwise distinct. Three cards are called a set if all $k$ features are good for them.
For example, the cards $(0, 0, 0)$, $(0, 2, 1)$, and $(0, 1, 2)$ form a set, but the cards $(0, 2, 2)$, $(2, 1, 2)$, and $(1, 2, 0)$ do not, as, for example, the last feature is not good.
A group of five cards is called a meta-set, if there is strictly more than one set among them. How many meta-sets there are among given $n$ distinct cards?
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le n \le 10^3$, $1 \le k \le 20$) β the number of cards on a table and the number of card features. The description of the cards follows in the next $n$ lines.
Each line describing a card contains $k$ integers $c_{i, 1}, c_{i, 2}, \ldots, c_{i, k}$ ($0 \le c_{i, j} \le 2$) β card features. It is guaranteed that all cards are distinct.
-----Output-----
Output one integer β the number of meta-sets.
-----Examples-----
Input
8 4
0 0 0 0
0 0 0 1
0 0 0 2
0 0 1 0
0 0 2 0
0 1 0 0
1 0 0 0
2 2 0 0
Output
1
Input
7 4
0 0 0 0
0 0 0 1
0 0 0 2
0 0 1 0
0 0 2 0
0 1 0 0
0 2 0 0
Output
3
Input
9 2
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
Output
54
Input
20 4
0 2 0 0
0 2 2 2
0 2 2 1
0 2 0 1
1 2 2 0
1 2 1 0
1 2 2 1
1 2 0 1
1 1 2 2
1 1 0 2
1 1 2 1
1 1 1 1
2 1 2 0
2 1 1 2
2 1 2 1
2 1 1 1
0 1 1 2
0 0 1 0
2 2 0 0
2 0 0 2
Output
0
-----Note-----
Let's draw the cards indicating the first four features. The first feature will indicate the number of objects on a card: $1$, $2$, $3$. The second one is the color: red, green, purple. The third is the shape: oval, diamond, squiggle. The fourth is filling: open, striped, solid.
You can see the first three tests below. For the first two tests, the meta-sets are highlighted.
In the first test, the only meta-set is the five cards $(0000,\ 0001,\ 0002,\ 0010,\ 0020)$. The sets in it are the triples $(0000,\ 0001,\ 0002)$ and $(0000,\ 0010,\ 0020)$. Also, a set is the triple $(0100,\ 1000,\ 2200)$ which does not belong to any meta-set.
In the second test, the following groups of five cards are meta-sets: $(0000,\ 0001,\ 0002,\ 0010,\ 0020)$, $(0000,\ 0001,\ 0002,\ 0100,\ 0200)$, $(0000,\ 0010,\ 0020,\ 0100,\ 0200)$.
In there third test, there are $54$ meta-sets. | n, k = map(int, input().split())
cards = [tuple(map(int, input().split())) for _ in range(n)]
cards_lookup, counter = {card: i for i, card in enumerate(cards)}, [0] * (n + 1)
for i in range(len(cards) - 1):
for j in range(i + 1, len(cards)):
counter[
cards_lookup.get(
tuple(
x if x == y else (x + 1 ^ y + 1) - 1
for x, y in zip(cards[i], cards[j])
),
-1,
)
] += 1
print(sum(x * (x - 1) // 2 for x in counter[:-1])) | ASSIGN 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 VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER 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, x1, y1 = map(int, input().split())
s_s = set()
for _ in range(n):
x2, y2 = map(int, input().split())
s_s.add((y2 - y1) / (x2 - x1) if x2 - x1 != 0 else "no slope")
print(len(s_s)) | 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 BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR STRING 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] | mod = 1000000007
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
ls = lambda: list(input())
n, x0, y0 = f()
l = []
for i in range(n):
a, b = f()
l.append([a, b])
bl = [0] * n
for i in range(n):
for j in range(n):
if bl[j] == 0 and (l[j][1] - y0) * (l[i][0] - x0) == (l[i][1] - y0) * (
l[j][0] - x0
):
bl[j] = i + 1
print(len(set(bl))) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER 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, xHanSolo, yHanSolo = map(int, input().split())
s = set()
inc = 0
for i in range(n):
xTroop, yTroop = map(int, input().split())
if yTroop != yHanSolo:
s.add((xTroop - xHanSolo) / (yTroop - yHanSolo))
else:
inc = 1
print(len(s) + inc) | 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 EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR 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] | from sys import stdin, stdout
def main():
from sys import stdin, stdout
n, o1, o2 = map(int, stdin.readline().split())
m = set()
for _ in range(n):
a, b = map(int, stdin.readline().split())
d1 = a - o1
d2 = b - o2
if d2:
m.add(d1 / d2)
else:
m.add("inf")
stdout.write(str(len(m)))
main() | 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR 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] | import sys
def get_array():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
n, x, y = get_ints()
myset = set()
for i in range(n):
X, Y = get_ints()
if X - x == 0:
slope = -(10**9) + 7
else:
slope = (Y - y) / (X - x)
myset.add(slope)
print(len(myset)) | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN 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 BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER 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] | def f():
n, x0, y0 = [int(x) for x in input().split()]
points = []
for i in range(n):
points.append([int(k) for k in input().split()])
shot = [False] * n
rez = 0
for i in range(n):
if shot[i]:
continue
shot[i] = True
rez += 1
A = points[i][1] - y0
B = -(points[i][0] - x0)
C = -A * x0 - B * y0
for j in range(i + 1, n):
if not shot[j] and A * points[j][0] + B * points[j][1] + C == 0:
shot[j] = True
print(rez)
f() | FUNC_DEF 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN 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] | class Point:
def __init__(self, x, y):
self.x = x
self.y = y
class Line:
def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
def __eq__(self, other):
l1 = Line(self.p1, other.p2)
l2 = Line(other.p1, self.p2)
return self.slopes_equal(self, other) and self.slopes_equal(l1, l2)
@staticmethod
def slopes_equal(l1, l2):
return (l1.p1.y - l1.p2.y) * (l2.p1.x - l2.p2.x) == (l2.p1.y - l2.p2.y) * (
l1.p1.x - l1.p2.x
)
def check():
origin = Point(0, 0)
p1 = Point(1, 1)
p2 = Point(2, 2)
print(Line.slopes_equal(Line(origin, p1), Line(origin, p2)))
print(Line(origin, p1) == Line(origin, p2))
def main():
n, ox, oy = [int(x) for x in input().split(" ")]
origin = Point(ox, oy)
lines = []
for _ in range(n):
px, py = [int(x) for x in input().split(" ")]
p = Point(px, py)
l = Line(origin, p)
for i in range(len(lines)):
line, freq = lines[i]
if l == line:
lines[i] = line, freq + 1
break
else:
lines.append((l, 1))
print(len(lines))
main() | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER 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 = list(map(int, input().split()))
troops = []
for i in range(n):
x, y = list(map(int, input().split()))
x = x - x0
y = y - y0
troops.append([x, y])
u_troops = []
for troop in troops:
flag = False
for u_troop in u_troops:
if troop[0] * u_troop[1] == troop[1] * u_troop[0]:
flag = True
break
if not flag:
u_troops.append(troop)
print(len(u_troops)) | 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 BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF 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] | t, x, y = list(map(int, input().split()))
INF = 10000000
s = set()
for tt in range(t):
x1, y1 = list(map(int, input().split()))
if y == y1:
s.add(INF)
else:
s.add((x - x1) / (y - y1))
print(len(s)) | ASSIGN VAR VAR VAR FUNC_CALL 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR 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())
ss = set()
for _ in range(0, n):
x1, y1 = map(int, input().split())
y2 = y1 - y0
x2 = x1 - x0
if x2 == 0:
ss.add("inf")
else:
ss.add(y2 / x2)
print(len(ss)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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] | class Node:
key = 0
left = None
right = None
def createNode(x):
newNode = Node()
newNode.key = x
return newNode
def searchNode(root, x):
if root == None or root.key == x:
return root
if root.key < x:
return searchNode(root.right, x)
return searchNode(root.left, x)
def insertNode(root, x):
if root == None:
return createNode(x)
if x < root.key:
root.left = insertNode(root.left, x)
elif x > root.key:
root.right = insertNode(root.right, x)
return root
def minValueNode(root):
current = root
while current.left != None:
current = current.left
return current
def deleteNode(root, x):
if root == None:
return root
if x < root.key:
root.left = deleteNode(root.left, x)
elif x > root.key:
root.right = deleteNode(root.right, x)
else:
if root.left == None:
temp = root.right
del root
return temp
elif root.right == None:
temp = root.left
del root
return temp
temp = minValueNode(root.right)
root.key = temp.key
root.right = deleteNode(root.right, temp.key)
return root
def createTree(a, n):
root = None
for i in range(n):
root = insertNode(root, a[i])
return root
def traversalTree(root):
if root != None:
traversalTree(root.left)
print(root.key, end=" ")
traversalTree(root.right)
def size(root):
if root == None:
return 0
return size(root.left) + 1 + size(root.right)
input_line = input().split()
n = int(input_line[0])
x0 = float(input_line[1])
y0 = float(input_line[2])
bonus = 0
root = None
for i in range(n):
x, y = map(float, input().split())
if y == y0:
bonus = 1
continue
root = insertNode(root, (x - x0) / (y - y0))
print(size(root) + bonus) | CLASS_DEF ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NONE FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF IF VAR NONE VAR VAR RETURN VAR IF VAR VAR RETURN FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR NONE RETURN FUNC_CALL 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 ASSIGN VAR VAR WHILE VAR NONE ASSIGN VAR VAR RETURN VAR FUNC_DEF IF VAR NONE RETURN VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NONE ASSIGN VAR VAR VAR RETURN VAR IF VAR NONE ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NONE EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR NONE RETURN NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR 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 NONE 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 FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP 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, x0, y0 = map(int, input().split())
xs = ys = 0
l = []
for i in range(n):
x, y = map(int, input().split())
if x0 == x:
xs = 1
elif y0 == y:
ys = 1
else:
m = (y - y0) / (x - x0)
l.append(m)
print(len(set(l)) + xs + ys) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR 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 BIN_OP FUNC_CALL VAR 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] | slopes = []
class point:
def __init__(self, coordinates):
self.x = coordinates[0]
self.y = coordinates[1]
def slope(self, p):
if self.x - p.x == 0:
return "undefined"
return (self.y - p.y) / (self.x - p.x)
values = list(map(int, input().split()))
n = values[0]
han_solo = point(values[1:])
for i in range(0, n):
trooper_i = point(list(map(int, input().split())))
slope_i = han_solo.slope(trooper_i)
if slope_i not in slopes:
slopes.append(slope_i)
print(slopes.__len__()) | ASSIGN VAR LIST CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN STRING RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR 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] | z, x, y = map(int, input().split())
c = set()
for i in range(z):
a, b = map(int, input().split())
if a - x == 0:
c.add(100000)
else:
c.add((b - y) / (a - x))
print(len(c)) | 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 IF BIN_OP VAR VAR NUMBER 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())
a = []
x = []
for i in range(0, n):
x = list(map(int, input().split()))
a.append(x)
s = set([])
c = 0
f1 = 0
f2 = 0
for i in range(0, n):
dy = y0 - a[i][1]
dx = x0 - a[i][0]
if dx == 0 and f1 == 0:
c += 1
f1 = 1
if dy == 0 and f2 == 0:
c += 1
f2 = 1
if dx != 0 and dy != 0:
t = dx / dy
if not t in s:
c += 1
s.add(dx / dy)
print(c) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST 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 FUNC_CALL VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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(x, y, a, b):
return (y - b) / (x - a) if x - a else float("inf")
def main():
n, x, y = (int(s) for s in input().split())
slopes = set()
for _ in range(n):
a, b = (int(s) for s in input().split())
slopes.add(slope(x, y, a, b))
print(len(slopes))
main() | FUNC_DEF RETURN BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR 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 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 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())
guys = []
for i in range(n):
x, y = (int(cur) for cur in input().split())
guys.append((x - x0, y - y0))
answer = 0
while guys:
cur_x, cur_y = guys[0]
k = 0
to_remove = []
for i in range(len(guys)):
x, y = guys[i]
if x * cur_y == y * cur_x:
to_remove.append(i - k)
k += 1
for index in to_remove:
del guys[index]
answer += 1
print(answer) | 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 BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER FOR VAR 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] | def fun():
se = set()
s = input().split()
a = int(s[1])
b = int(s[2])
cnt = 0
for i in range(int(s[0])):
temp = input().split()
c = int(temp[0])
d = int(temp[1])
if c == a:
cnt = 1
continue
se.add((d - b) / (c - a))
ans = len(se) + cnt
print(ans)
fun() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR 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] | def value():
n, x0, y0 = input().split()
n, x0, y0 = int(n), int(x0), int(y0)
ks = set()
x_axis = 0
y_axis = 0
for i in range(n):
x, y = input().split()
x, y = int(x), int(y)
if y - y0 == 0:
x_axis = 1
continue
if x - x0 == 0:
y_axis = 1
continue
k = (y - y0) / (x - x0)
ks.add(k)
m = int(len(ks))
print(m + x_axis + y_axis)
value() | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 NUMBER 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP 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, x0, y0 = [int(i) for i in input().split()]
d = {}
for i in range(n):
x, y = [int(j) for j in input().split()]
if x == x0:
if "o" not in d.keys():
d["o"] = 1
else:
line = (y - y0) / (x - x0)
if line not in d.keys():
d[line] = 1
print(len(d)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF STRING FUNC_CALL VAR ASSIGN VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR FUNC_CALL 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] | def mi():
return map(int, input().split(" "))
n, a, b = mi()
li = []
flag = False
for i in range(n):
x, y = mi()
if y - b == 0:
flag = True
else:
li.append((x - a) / (y - b))
print(len(set(li)) + int(flag)) | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER 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 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 solution():
n, x0, y0 = map(int, input().strip().split())
shots = set()
for i in range(n):
x, y = map(int, input().strip().split())
x, y = x - x0, y - y0
angle = 10000.0
if y != 0:
angle = x / y
shots.add(angle)
print(len(shots))
solution() | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL 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] | a = [int(x) for x in input().split()]
n = a[0]
x1 = a[1]
y1 = a[2]
b = []
for i in range(n):
x, y = [int(x) for x in input().split()]
if y1 - y == 0:
b.append("infinite")
else:
b.append((x1 - x) / (y1 - y))
s = set(b)
print(len(s)) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP 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 shib(x0, y0, x1, y1):
try:
k = (y1 - y0) / (x1 - x0)
except:
k = 1e-05
return k
ans = set()
t, x0, y0 = map(int, input().split())
for _ in range(t):
x, y = map(int, input().split())
ans.add(shib(x0, y0, x, y))
print(len(ans)) | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER RETURN VAR 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 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] | en, x0, y0 = map(int, input().split())
r = 0
dic = {}
for i in range(en):
x, y = map(int, input().split())
if x != x0:
t = float(y - y0) / float(x - x0)
dic[t] = 1
else:
r = 1
for a in dic:
r += dic[a]
print(r) | 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 VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR 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 isequal(a, b):
return abs(a - b) <= 1e-08
a, b, c = map(int, input().split(" "))
slopes = []
for i in range(a):
x, y = map(int, input().split(" "))
if x == b:
slopes.append(90001)
else:
slopes.append((y - c) / (x - b))
print(len(set(slopes))) | FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST 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 NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP 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] | class Point:
def __init__(self, x, y):
self.x = int(x)
self.y = int(y)
s = set()
n, han_x, han_y = [int(x) for x in input().split()]
lst = list()
flag = False
han = Point(han_x, han_y)
for i in range(n):
lst.append(Point(*input().split(" ")))
if lst[i].x - han.x == 0:
flag = True
else:
sloap = (lst[i].y - han.y) / (lst[i].x - han_x)
s.add(sloap)
print(len(s) + flag) | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR 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, sx, sy = map(int, input().split())
d = {}
count = 0
for i in range(n):
fx, fy = map(int, input().split())
up = fy - sy
down = fx - sx
if down == 0:
if 10000 not in d.keys():
d[10000] = 1
count += 1
else:
t = up / down
if t not in d.keys():
d[t] = 1
count += 1
print(count) | 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 ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF NUMBER FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR FUNC_CALL 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] | n, x, y = map(int, input().split())
l = []
for i in range(0, n):
a = tuple(map(int, input().split()))
b = True
for i in l:
if (i[1] - y) * (a[0] - x) == (a[1] - y) * (i[0] - x):
b = False
if b is True:
l.append(a)
print(len(l)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER IF 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 = input().split()
x = []
y = []
tg = []
target = []
Ans = 0
n = int(a[0])
x0 = int(a[1])
y0 = int(a[2])
for i in range(n):
a = input().split()
x.append(int(a[0]))
y.append(int(a[1]))
if y[i] - y0 != 0:
tg.append((x[i] - x0) / (y[i] - y0))
else:
tg.append("inf")
done = True
while done:
k = tg[0]
for i in range(tg.count(k)):
tg.remove(k)
Ans += 1
if tg == []:
done = False
print(Ans) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR LIST ASSIGN 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] | slopes = set()
ans = 0
n, x0, y0 = map(int, input().strip().split())
for i in range(n):
x, y = list(map(int, input().strip().split()))
if x == x0:
ans = 1
else:
slopes.add((y - y0) / (x - x0))
print(len(slopes) + ans) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL 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 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] | for t in range(1):
n, x, y = map(int, input().split())
slope = set()
for i in range(n):
pos_x, pos_y = map(int, input().split())
pos_x, pos_y = pos_x - x, pos_y - y
if pos_x != 0:
m = pos_y / pos_x
slope.add(m)
else:
slope.add(10**10)
print(len(slope)) | FOR VAR FUNC_CALL VAR NUMBER 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 ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP 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, x, y = input().split(" ")
troops = []
for i in range(int(n)):
a, b = input().split(" ")
troops.append([int(a) - int(x), int(b) - int(y)])
s = set()
for troop in troops:
if troop[0] != 0:
s.add(troop[1] / troop[0])
else:
s.add(1000000)
print(len(s)) | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL 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
input = sys.stdin.readline
n, x, y = map(int, input().split())
coord = []
for i in range(n):
coord.append(list(map(int, input().split())))
c = []
ok = 0
for i in range(n):
y1 = coord[i][1]
x1 = coord[i][0]
if x1 == x:
ok = 1
continue
k = (y1 - y) / (x1 - x)
c.append(k)
print(len(set(c)) + ok) | IMPORT ASSIGN VAR VAR 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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR 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 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
n, x_0, y_0 = map(int, stdin.readline().rstrip().split())
s = set()
for i in range(n):
x, y = map(int, stdin.readline().rstrip().split())
x_diff = float(x - x_0)
y_diff = float(y - y_0)
if x_diff != 0:
s.add(y_diff / x_diff)
else:
s.add(float("inf"))
stdout.write(str(len(s)) + "\n") | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR STRING |
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 solve(r, w):
data = r.readline().split()
num_troopers = int(data[0])
gun_coord = int(data[1]), int(data[2])
extra = 0
shots = set()
for _ in range(num_troopers):
data = r.readline().split()
trooper_coords = int(data[0]), int(data[1])
if trooper_coords[1] - gun_coord[1] != 0:
shots |= {
(gun_coord[0] - trooper_coords[0]) / (gun_coord[1] - trooper_coords[1])
}
else:
extra = 1
print(len(shots) + extra)
solve(sys.stdin, sys.stdout) | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR EXPR 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 gcd(a, b):
return a if b == 0 else gcd(b, a % b)
[n, x0, y0] = list(map(int, input().split(" ")))
s = set({})
for i in range(n):
[x, y] = list(map(int, input().split(" ")))
dx, dy = x - x0, y - y0
s.add("Y" if dy == 0 else dx / dy)
print(len(s)) | FUNC_DEF RETURN VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP 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] | import sys
n, x0, y0 = map(int, input().split())
slopes = set({})
for i in range(n):
x, y = map(int, input().split())
if x - x0 != 0:
slopes.add((y - y0) / (x - x0))
else:
slopes.add(1000000000)
print(len(slopes)) | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL 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 s(x0, y0, x, y):
if x0 == x:
return "inf"
return (int(y0) - int(y)) / (int(x0) - int(x))
n, x0, y0 = input().split()
n = int(n)
slopes = set()
while n != 0:
x, y = input().split()
slopes.add(s(x0, y0, x, y))
n -= 1
print(len(slopes)) | FUNC_DEF IF VAR VAR RETURN STRING RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR 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 WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL 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 = list(map(int, input().split()))
k = [float("inf") for i in range(n)]
for i in range(n):
xi, yi = list(map(int, input().split()))
if xi != x:
k[i] = (yi - y) / (xi - x)
k = len(set(k))
print(k) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL 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 collinear(c0, c1, c2):
return (c1[1] - c0[1]) * (c2[0] - c0[0]) == (c2[1] - c0[1]) * (c1[0] - c0[0])
num_troopers, x0, y0 = [int(s) for s in input().split(" ")]
gun = [x0, y0]
troops = []
for t in range(num_troopers):
coord = [int(s) for s in input().split(" ")]
troops.append(coord)
shots = 0
while len(troops) > 0:
if len(troops) == 1:
shots += 1
break
curr = troops[0]
rest_of_troops = []
for troop in troops[1:]:
if not collinear(gun, curr, troop):
rest_of_troops.append(troop)
troops = rest_of_troops
shots += 1
print(shots) | FUNC_DEF RETURN 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 ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL 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] | n, x0, y0 = map(int, input().split())
l = []
for _ in range(n):
x, y = map(int, input().split())
l.append([x, y])
ans = 0
z = [0] * n
for i in range(n - 1):
if z[i] == 0:
ans += 1
z[i] = 1
for j in range(i + 1, n):
if (l[j][1] - y0) * (l[i][0] - x0) == (l[j][0] - x0) * (l[i][1] - y0) and z[
j
] == 0:
z[j] = 1
v = 0
for i in range(n):
if z[i] == 1:
v += 1
if v == n - 1:
ans += 1
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 LIST VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP 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())
res = []
for i in range(n):
x, y = map(int, input().split())
if x == x0:
res.append("target")
else:
res.append(float(y - y0) / float(x - x0))
print(len(set(res))) | 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 VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP 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] | f = lambda: map(int, input().split())
n, a, b = f()
l = set()
for i in range(0, n):
x, y = f()
l.add((y - b) / (x - a) if x != a else float("INF"))
print(len(l)) | 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 FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_CALL VAR STRING 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] | while True:
try:
def solution(n, x, y, cordinates):
i = j = 0
cunt = 0
while i < n:
j = i + 1
match = False
while j < n:
if cordinates[i] == [-(10**5), -(10**5)]:
break
if (
cordinates[j] != [-(10**5), -(10**5)]
and (cordinates[i][0] - x) * (cordinates[j][1] - y)
) == (cordinates[j][0] - x) * (cordinates[i][1] - y):
match = True
cordinates[j] = [-(10**5), -(10**5)]
j += 1
if match:
cunt += 1
cordinates[i] = [-(10**5), -(10**5)]
i += 1
for i in range(n):
if cordinates[i] != [-(10**5), -(10**5)]:
cunt += 1
print(cunt)
def read():
n, x0, y0 = map(int, input().split())
cordinates = list()
for i in range(n):
x1, y1 = map(int, input().split())
cordinates.append([x1, y1])
solution(n, x0, y0, cordinates)
if __name__ == "__main__":
read()
except EOFError:
break | WHILE NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER IF VAR VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR LIST BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR IF 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] | read = lambda: list(map(int, input().split()))
params = read()
n, x, y = params[0], params[1], params[2]
slopes = set()
for i in range(n):
point = read()
diffx = point[0] - x
diffy = point[1] - y
if diffx == 0:
slope = "inf"
elif diffy == 0:
slope = "0"
else:
slope = str(diffy / diffx)
slopes.add(slope)
print(len(slopes)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL 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] | INF = 1000000000.0
def shib(x0, y0, x1, y1):
if x0 - x1 == 0:
return INF
return (y0 - y1) / (x0 - x1)
n, x, y = map(int, input().split())
shibs = []
total = 0
for _ in range(n):
x1, y1 = map(int, input().split())
m = shib(x, y, x1, y1)
if m not in shibs:
shibs.append(m)
total += 1
print(total) | ASSIGN VAR NUMBER FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN VAR 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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR 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] | n, x0, y0 = map(int, input().split())
d = {}
for i in range(n):
x, y = map(int, input().split())
y = y - y0
x = x - x0
if x == 0:
m = "O"
else:
m = y / x
d[m] = 0
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 ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR STRING ASSIGN 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] | def main():
n, x0, y0 = tuple(list(map(int, input().split())))
troopers = []
s = set()
for x in range(n):
x, y = tuple(list(map(int, input().split())))
if x - x0 != 0:
slope = (y - y0) / (x - x0)
s.add(slope)
else:
s.add("infty")
return len(s)
print(main()) | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL 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 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] | r = lambda: map(int, input().split())
n, x, y = r()
d = set()
for _ in range(n):
s_x, s_y = r()
d_x, d_y = x - s_x, y - s_y
m = max(abs(d_x), abs(d_y))
d_x /= m
d_y /= m
d.add((d_x, d_y))
d.add((-d_x, -d_y))
print(len(d) // 2) | 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 FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR 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 = []
for i in range(n):
c, b = map(int, input().split())
a.append((c, b))
k = 0
while a:
c, b = a[0][0], a[0][1]
a.remove(a[0])
r = []
for i in range(len(a)):
if (a[i][0] - x) * (b - y) == (a[i][1] - y) * (c - x):
r.append(a[i])
for i in range(len(r)):
a.remove(r[i])
k += 1
print(k) | 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 NUMBER WHILE VAR ASSIGN VAR VAR VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL 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] | n, x1, y1 = map(int, input().split())
ar = []
for i in range(n):
x2, y2 = map(int, input().split())
try:
sp = (y2 - y1) / (x2 - x1)
except ZeroDivisionError:
sp = "a"
if sp not in ar:
ar.append(sp)
print(len(ar)) | 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 ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR 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, x0, y0 = map(int, input().split(" "))
n1 = n
coords = []
while n1:
n1 -= 1
coords.append(list(map(int, input().split(" "))))
for coord in coords:
coord[0] -= x0
coord[1] -= y0
fire = 0
temp = []
for i in range(n):
if coords[i][0] == 0:
temp.append(i)
if len(temp):
fire += 1
for i in temp[::-1]:
coords.pop(i)
def deletecoords(slope):
temp = []
for i in range(len(coords)):
if coords[i][1] / coords[i][0] == slope:
temp.append(i)
for i in temp[::-1]:
coords.pop(i)
while len(coords):
coord = coords[0]
slope = coord[1] / coord[0]
deletecoords(slope)
fire += 1
print(fire) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR VAR NUMBER VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER 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, x, y = list(map(int, input().split(" ")))
Meow = set()
for i in range(n):
a, b = list(map(int, input().split(" ")))
a -= x
b -= y
if b == 0:
Meow.add(100000)
else:
arg = a / b
Meow.add(arg)
print(len(Meow)) | ASSIGN VAR VAR VAR FUNC_CALL 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL 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] | import sys
def solve():
n, x0, y0 = read()
stormtroopers = list()
for i in range(n):
xi, yi = read()
temp = xi, yi
stormtroopers.append(temp)
shots = 0
while len(stormtroopers) > 0:
cur = stormtroopers.pop()
shots += 1
if cur[0] - x0 == 0:
remstormtroopers = [point for point in stormtroopers if point[0] != x0]
else:
slope = (cur[1] - y0) / (cur[0] - x0)
remstormtroopers = [
point
for point in stormtroopers
if abs(point[1] - y0 - slope * (point[0] - x0)) > 1e-06
]
stormtroopers = remstormtroopers
return shots
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))
if isinstance(s, tuple):
s = " ".join(map(str, s))
s = str(s)
print(s, end="")
def run():
if sys.hexversion == 50594544:
sys.stdin = open("test.txt")
res = solve()
write(res)
run() | IMPORT 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 ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR RETURN 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 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 FUNC_DEF IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR 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] | string = input().split()
trials = int(string[0])
han_solo_x, han_solo_y = [int(string[1]), int(string[2])]
ratioz = set()
gottem = False
for x in range(trials):
get = input().split()
if int(get[1]) - han_solo_y == 0:
gottem = True
else:
ratioz.add((int(get[0]) - han_solo_x) / (int(get[1]) - han_solo_y))
amt = 1 if gottem else 0
amt += len(ratioz)
print(amt) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER 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] | n, x0, y0 = [int(x) for x in input().split()]
s = set()
for i in range(n):
x, y = [int(x) for x in input().split()]
if y == y0:
s.add(float("inf"))
else:
m = (x - x0) / (y - y0)
s.add(m)
print(len(s)) | ASSIGN VAR VAR VAR FUNC_CALL VAR 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 VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR 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] | def gcd(a, b):
while b:
r = a % b
a = b
b = r
return a
s = set()
n, x0, y0 = map(int, input().split())
for i in range(n):
x, y = map(int, input().split())
x1 = x - x0
y1 = y - y0
if x1 < 0:
x1 *= -1
y1 *= -1
if x1 == 0:
y1 = abs(y1)
d = gcd(abs(x1), abs(y1))
s.add((x1 / d, y1 / d))
print(len(s)) | FUNC_DEF WHILE VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR 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 BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR 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())
x = [None for i in range(n)]
y = [None for i in range(n)]
m_xy = {}
for i in range(n):
xi, yi = map(int, input().split())
x[i] = xi
y[i] = yi
if x[i] - x0 != 0:
m = (y[i] - y0) / (x[i] - x0)
else:
m = "Inf"
if m not in m_xy:
m_xy[m] = []
m_xy[m].append((xi, yi))
print(len(m_xy)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR 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 ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR STRING IF VAR VAR ASSIGN VAR VAR LIST 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] | s = set()
max = 1e19
inp = input()
n = int(inp.split()[0])
x = int(inp.split()[1])
y = int(inp.split()[2])
for i in range(n):
inp = input()
a = int(inp.split()[0])
b = int(inp.split()[1])
if a == x:
k = max
c = x
else:
k = (b - y) / (a - x)
c = y - k * x
s.add((k, c))
print(len(s)) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR 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, x0, y0 = map(int, input().split())
ms = set()
origin = 0
for i in range(n):
xi, yi = map(int, input().split())
if xi - x0 == 0 and yi == y0:
origin = 1
elif xi - x0 == 0:
ms.add("vertical")
else:
ms.add((yi - y0) / (xi - x0))
sol = len(ms)
if sol == 0:
sol = origin
print(str(sol)) | 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 VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN 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, gx, gy = map(int, input().split())
sx = []
sy = []
ded = 999999999999
slopes = []
for i in range(n):
a, b = map(int, input().split())
sx.append(a)
sy.append(b)
def slope(x):
if sx[x] - gx == 0:
return ded
else:
return (sy[x] - gy) / (sx[x] - gx)
for i in range(n):
slopes.append(slope(i))
print(len(set(slopes))) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER 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 EXPR FUNC_CALL VAR VAR FUNC_DEF IF BIN_OP VAR VAR VAR NUMBER RETURN VAR RETURN BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR 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] | n, x, y = map(int, input().split(" "))
c = list()
for i in range(0, n):
a, b = map(int, input().split(" "))
if x - a != 0:
l = (y - b) / (x - a)
elif x - a == 0 and y - b == 0:
l = 1
elif x - a == 0 and y - b != 0:
l = 100000
c.append(l)
c = set(c)
print(len(c)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER 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] | n, x0, y0 = map(int, input().split())
l = []
for i in range(1, n + 1):
x, y = map(int, input().split())
if x0 - x == 0:
l.append(-1000)
else:
m = (y0 - y) / (x0 - x)
l.append(m)
l = list(dict.fromkeys(l))
print(len(l)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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, x0, y0 = list(map(int, input().split()))[:3]
xys = []
for _ in range(n):
xys.append(tuple(list(map(int, input().split()))[:2]))
slopes = []
for i in xys:
slopes.append((i[1] - y0) / (i[0] - x0)) if i[0] - x0 != 0 else slopes.append("a")
print(len(set(slopes))) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR 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, x, y = map(int, input().split())
M = [list(map(int, input().split())) for i in range(n)]
l = []
k = 0
def evklid(a, b):
if a == 0:
return b
if b == 0:
return a
if a % b == 0:
return b
else:
return evklid(b, a % b)
for i in range(n):
x1 = M[i][0] - x
y1 = M[i][1] - y
c = 0
if x1 < 0 and y1 < 0:
x1 = abs(x1)
y1 = abs(y1)
if x1 < 0 and y1 > 0 or x1 > 0 and y1 < 0:
c = 1
x1 = abs(x1)
y1 = abs(y1)
d = evklid(x1, y1)
x1 = x1 // d
y1 = y1 // d
if c == 1:
x1 = -x1
if [x1, y1] not in l:
k = k + 1
l.append([x1, y1])
print(k) | 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 LIST ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN VAR IF BIN_OP VAR VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF LIST VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER 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] | info = [int(num) for num in input().split()]
n = info[0]
gun_x = info[1]
gun_y = info[2]
slopes = []
need_vertical = False
for _ in range(n):
trooper_info = [int(num) for num in input().split()]
trooper_x = trooper_info[0]
trooper_y = trooper_info[1]
if trooper_x != gun_x:
given_slope = (trooper_y - gun_y) / (trooper_x - gun_x)
if given_slope not in slopes:
slopes.append(given_slope)
else:
need_vertical = True
result = len(slopes)
if need_vertical:
result += 1
print(result) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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] | from sys import stdin
INF = 9999999999999999
live = True
if not live:
stdin = open("data.in", "r")
n, x0, y0 = list(map(int, stdin.readline().strip().split()))
coords = []
pante = []
for it in range(n):
x, y = list(map(int, stdin.readline().strip().split()))
coords += [(x, y)]
for x, y in coords:
if x0 == x:
pante += [INF]
else:
pante += [(y - y0) / (x - x0)]
pante = sorted(pante)
ans = 1
curr = pante[0]
for it in pante:
if it != curr:
ans += 1
curr = it
print(ans)
if not live:
stdin.close() | ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR FOR VAR VAR VAR IF VAR VAR VAR LIST VAR VAR LIST BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR IF 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] | def coeff(x1, y1, x2, y2):
a = y2 - y1
b = x1 - x2
c = -a * x1 - b * y1
return a, b, c
def PointOnLine(x, y, a, b, c):
if a * x + b * y + c == 0:
return True
else:
return False
n, x0, y0 = map(int, input().split())
s = set()
x = []
y = []
ans = 0
for i in range(n):
a, b = map(int, input().split())
x.append(a)
y.append(b)
for i in range(n):
if (x[i], y[i]) not in s:
a, b, c = coeff(x0, y0, x[i], y[i])
for i in range(n):
if PointOnLine(x[i], y[i], a, b, c):
s.add((x[i], y[i]))
ans += 1
print(ans) | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR VAR VAR 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 ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR 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] | import sys
n, xGun, yGun = map(int, input().split())
lines = {}
for i in range(n):
x1, y1 = map(int, input().split())
if xGun - x1 != 0:
slope = (yGun - y1) / (xGun - x1)
lines[slope] = 1
else:
lines[sys.maxsize] = 1
print(len(lines)) | IMPORT 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 BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN 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] | num_troops, x_han, y_han = map(int, input().split())
troops = []
slopes = set()
for i in range(num_troops):
x, y = map(int, input().split())
troops.append((x, y))
for t in troops:
run = t[0] - x_han
rise = t[1] - y_han
if run == 0:
slopes.add(float("inf"))
else:
slopes.add(rise / run)
print(len(slopes)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST 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 VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR 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] | def gcd(a, b):
if a < 0:
a = -a
if b < 0:
b = -b
if a < b:
return gcd(b, a)
if b == 0:
return a
return gcd(b, a % b)
def solve():
n, x, y = map(int, input().rstrip().split())
count = set()
for _ in range(n):
a, b = map(int, input().rstrip().split())
c = a - x
d = b - y
if c < 0 and d < 0:
c = -c
d = -d
elif d < 0:
c = -c
d = -d
g = gcd(c, d)
if d == 0:
count.add(0)
elif c == 0:
count.add("inf")
else:
count.add((c // g, d // g))
print(len(count))
solve() | FUNC_DEF IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR RETURN FUNC_CALL VAR VAR VAR IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP 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] | import sys
f = sys.stdin
n, x0, y0 = map(int, f.readline().strip().split())
xy = []
for i in range(n):
xy.append(list(map(int, f.readline().strip().split())))
used = [0] * n
v = 0
for i in range(n):
if used[i] == 0:
v += 1
used[i] = 1
kx = x0 - xy[i][0]
ky = y0 - xy[i][1]
if kx < 0:
kx *= -1
ky *= -1
if kx == 0 and ky < 0:
ky *= -1
for j in range(i, n):
if used[j] == 0:
kxj = x0 - xy[j][0]
kyj = y0 - xy[j][1]
if kxj < 0:
kxj *= -1
kyj *= -1
if kxj == 0 and kyj < 0:
kyj *= -1
if kx * kyj == ky * kxj:
used[j] = 1
print(v) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER 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(i) for i in input().split()]
N = 0
lines = []
for i in range(n):
x, y = [int(i) for i in input().split()]
if x == x0:
m = 1e100
b = 1e100
else:
m = (y - y0) / (x - x0)
b = y0 - m * x0
lines.append((m, b))
print(len(set(lines))) | 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 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 VAR BIN_OP VAR VAR EXPR 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] | n, x, y = list(map(int, input().split()))
a = {"*"}
for _ in range(n):
d, e = list(map(int, input().split()))
if d == x:
if float("inf") in a:
continue
else:
a.add(float("inf"))
continue
if e == y:
if 0 in a:
continue
else:
a.add(0)
continue
t = (e - y) / (d - x)
if t in a:
continue
else:
a.add(t)
print(len(a) - 1) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR STRING IF VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR EXPR 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] | a = input()
n = int(a.split()[0])
l = list(map(int, a.split()[1:]))
t = []
q = []
count = n
for i in range(n):
c = input()
u = list(map(int, c.split()))
t.append(u)
if t[i][0] - l[0] != 0:
q.append((t[i][1] - l[1]) / (t[i][0] - l[0]))
else:
q.append("inf")
print(len(set(q))) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER 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] | def numberKills(n, x, y):
count = 0
isDead = [(0) for i in range(n)]
position = list()
for i in range(n):
position.append([int(i) for i in input().split()])
for i in range(n):
if not isDead[i]:
count += 1
dx1 = position[i][0] - x
dy1 = position[i][1] - y
for j in range(n):
dx2 = position[j][0] - x
dy2 = position[j][1] - y
if dx2 * dy1 == dx1 * dy2:
isDead[j] = 1
return count
temp = [int(i) for i in input().split()]
print(numberKills(temp[0], temp[1], temp[2])) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR 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 RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER 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, x0, y0 = [int(i) for i in input().split()]
ans = 0
points = set()
for i in range(n):
tmp = [int(j) for j in input().split()]
if tmp[1] == y0:
ans = 1
else:
points.add((tmp[0] - x0) / (tmp[1] - y0))
ans += len(points)
print(ans) | 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 VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER 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] | import itertools
n, x0, y0 = [int(x) for x in input().split()]
target = []
for i in range(n):
x, y = [int(x) for x in input().split()]
cos2 = (x - x0) ** 2 / ((x - x0) ** 2 + (y - y0) ** 2)
target.append(cos2 if (x - x0) * (y - y0) >= 0 else -cos2)
target.sort()
L = list(itertools.groupby(target))
print(len(L)) | 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 BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL 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, x0, y0 = [int(i) for i in input().split(" ")]
l = set()
vertical = 0
for i in range(n):
x1, y1 = [int(i) for i in input().split(" ")]
if x1 - x0 == 0:
vertical = 1
else:
l.add((y1 - y0) / (x1 - x0))
print(len(l) + vertical) | ASSIGN VAR VAR VAR FUNC_CALL VAR 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 VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER 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 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())
slopes = []
for _ in range(n):
x1, y1 = map(int, input().split())
x1 -= x
y1 -= y
if x1 == 0:
slope = "i"
else:
slope = y1 / x1
slopes.append(slope)
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 ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR STRING ASSIGN 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] | 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 = float("INF")
else:
m = (y - y1) / (x - x1)
if m not in d:
d.append(m)
ans += 1
print(ans) | 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR 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] | def sameLine(points):
x0, y0 = points[0]
points = [(x, y) for x, y in points if x != x0 or y != y0]
slopes = [((y - y0) / (x - x0) if x != x0 else None) for x, y in points]
return set(slopes)
n = list(map(int, input().split()))
tp = n[0]
p0 = n[1:]
s = []
s.append(p0)
for i in range(tp):
s.append(list(map(int, input().split())))
l = len(sameLine(s))
print(l) | FUNC_DEF ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NONE VAR VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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] | n, x, y = map(int, input().split())
a = []
for i in range(n):
x1, y1 = map(int, input().split())
a.append((x1, y1))
d = {}
for p, q in a:
if p == x:
d[float("inf")] = True
else:
d[(q - y) / (p - x)] = True
print(len(d)) | 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 DICT FOR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP 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 gdc(a, b):
if b == 0:
return a
return gdc(b, a % b)
n, x0, y0 = map(int, input().split())
d = {}
for i in range(n):
x, y = map(int, input().split())
x -= x0
y -= y0
k = gdc(abs(x), abs(y))
x //= k
y //= k
if y == 0:
d["0"] = 0
elif x == 0:
d["1"] = 0
elif x < 0:
y *= -1
x *= -1
s = str(y) + " " + str(x)
d[s] = 0
else:
s = str(y) + " " + str(x)
d[s] = 0
print(len(d)) | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR STRING NUMBER IF VAR NUMBER ASSIGN VAR STRING NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL 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, x, y = map(int, input().split())
us = []
c = 0
while n:
n -= 1
tx, ty = map(int, input().split())
if tx - x != 0:
temps = (ty - y) / (tx - x)
else:
temps = "bruh"
if temps not in us:
us.append(temps)
c += 1
print(c) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR NUMBER 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 ASSIGN VAR STRING 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, x0, y0 = map(int, input().split())
slopes = {}
for i in range(n):
x, y = map(int, input().split())
num = y - y0
den = x - x0
if den == 0 and "inf" in slopes:
slopes["inf"] += 1
elif den == 0:
slopes["inf"] = 1
else:
found = False
for s in slopes:
if isinstance(s, tuple) and num * s[1] == den * s[0]:
slopes[s] += 1
found = True
if found == False:
slopes[num, den] = 1
print(slopes.__len__()) | 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 BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER STRING VAR VAR STRING NUMBER IF VAR NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER 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] | def m(c1, c2):
try:
return (c2[1] - c1[1]) / (c2[0] - c1[0])
except:
return "inf"
n, x0, y0 = map(int, input().split())
arr = []
dic = {}
for _ in range(n):
arr.append(tuple(map(int, input().split())))
for i in arr:
sl = m((x0, y0), i)
if sl in dic:
dic[sl] += 1
else:
dic[sl] = 1
final = len(dic)
print(final) | FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER RETURN STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN 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] | n, x0, y0 = map(int, input().split())
RelCoords = list()
for _ in range(n):
x, y = map(int, input().split())
RelCoords.append((x - x0, y - y0))
SlopeSet = set()
VerticalLine = False
for x, y in RelCoords:
if not x:
VerticalLine = True
else:
SlopeSet.add(y / x)
print(len(SlopeSet) + VerticalLine) | 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 BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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
input = sys.stdin.readline
n, x0, y0 = map(int, input().split())
x, y = [], []
for i in range(n):
xi, yi = map(int, input().split())
x.append(xi - x0)
y.append(yi - y0)
res = 0
for i in range(n):
if x[i] == 0 and y[i] == 0:
continue
for j in range(i + 1, n):
if x[i] == 0:
if x[j] == 0:
y[j] = 0
elif x[j] != 0:
if y[i] / x[i] == y[j] / x[j]:
x[j] = 0
y[j] = 0
x[i] = 0
y[i] = 0
res += 1
print(res) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER 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] | nxy = list(map(int, input().split()))
n = nxy[0]
xGun = nxy[1]
yGun = nxy[2]
horz = 0
vert = 0
other = 0
mlist = []
if (
n >= 1
and n <= 1000
and xGun >= -(10**4)
and xGun <= 10**4
and yGun >= -(10**4)
and yGun <= 10**4
):
for i in range(n):
xy = list(map(int, input().split()))
if (
xy[0] >= -(10**4)
and xy[0] <= 10**4
and xy[1] >= -(10**4)
and xy[1] <= 10**4
):
if xGun == xy[0]:
vert += 1
elif yGun == xy[1]:
horz += 1
elif (yGun - xy[1]) / (xGun - xy[0]) not in mlist:
mlist.append((yGun - xy[1]) / (xGun - xy[0]))
other += 1
if horz >= 1:
other += 1
if vert >= 1:
other += 1
print(other) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER BIN_OP NUMBER NUMBER VAR NUMBER BIN_OP NUMBER NUMBER VAR NUMBER BIN_OP NUMBER NUMBER VAR NUMBER BIN_OP NUMBER NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR VAR NUMBER 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 IF VAR NUMBER VAR NUMBER IF 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 inp():
return map(int, input().split())
def solve():
n, x0, y0 = inp()
x = [0] * n
y = x[:]
check = x[:]
for i in range(n):
x[i], y[i] = inp()
res = 0
for i in range(n):
a = y0 - y[i]
b = x[i] - x0
if check[i] == 1:
continue
check[i] = 1
res += 1
for j in range(i + 1, n):
if check[j] == 0 and a * (x[j] - x0) + b * (y[j] - y0) == 0:
check[j] = 1
print(res)
solve() | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER ASSIGN 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] | lst = list(map(int, input().split()))
s = set()
a, b, c = lst
for _ in range(a):
x = list(map(int, input().split()))
if x[0] != b:
s.add(float(x[1] - c) / float(x[0] - b))
else:
s.add("yes")
print(len(s)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR STRING 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 _ in range(n):
a, b = map(int, input().split())
if b - y != 0 and (a - x) / (b - y) not in d:
d[(a - x) / (b - y)] = 1
elif b - y == 0:
d["inf"] = 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 BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER IF 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 = [int(x) for x in input().split()]
start = n[1], n[2]
slope_set = set()
for x in range(n[0]):
points = input().split()
point = [int(y) for y in points]
val_x = point[0] - start[0]
val_y = point[1] - start[1]
if val_x == 0:
slope_set.add(("x", point[0]))
else:
slope_set.add((point[1] - start[1]) / (point[0] - start[0]))
print(len(slope_set)) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP 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] | n, x0, y0 = map(int, input().split(" "))
troopers = set()
for i in range(n):
xi, yi = map(int, input().split(" "))
troopers.add((xi - x0, yi - y0))
nb = 0
while len(troopers) != 0:
nb += 1
target = next(iter(troopers))
deleted = set()
for t in troopers:
if t[0] * target[1] == t[1] * target[0]:
deleted.add(t)
troopers -= deleted
print(nb) | 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 EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR 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 = [int(x) for x in input().split()]
slope_dict = dict()
coords = list()
BIG_NUM = 10**9 + 7
for i in range(n):
x, y = [int(a) for a in input().split()]
coords.append((x - x0, y - y0))
for i in range(len(coords)):
cur_x, cur_y = coords[i]
if cur_y == 0:
if BIG_NUM in slope_dict:
slope_dict[BIG_NUM] += 1
else:
slope_dict[BIG_NUM] = 1
else:
slope = cur_x / cur_y
if slope in slope_dict:
slope_dict[slope] += 1
else:
slope_dict[slope] = 1
print(len(slope_dict.keys())) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER 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 VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN 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] | n, x0, y0 = map(int, input().split())
counter = 0
shots = set()
INF = False
for i in range(n):
x, y = map(int, input().split())
if x - x0 == 0:
INF = True
else:
k = (y - y0) / (x - x0)
shots.add(k)
if INF == True:
print(len(shots) + 1)
else:
print(len(shots)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.