about summary refs log tree commit diff
path: root/NTU/TutOnEqua.c
blob: 84cec70467c615f34306df60c8382d1e8a9c6b09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>

#define abs(x) (x < 0) ? -x : x

int gcd(int a, int b)
{
	int c;

	while (b) {
		c = a % b;
		a = b;
		b = c;
	}

	return a;
}

int main()
{
	int a, b, c, i, j, k, l, m, n, t;
	char solutions[201][100];

	scanf("%d", &t);
	for (i = t; i; i--) {
		for (k = 0; k < 201; k++)
			for (l = 0; l < 100; l++)
				solutions[k][l] = 0;

		scanf("%d", &n);
		for (j = n; j; j--) {
			scanf("%d %d", &a, &b);
			if (a) {
				c = gcd(a, b);

				if (a * b < 0)
					a = -abs(a / c) + 100;
				else
					a = abs(a / c) + 100;
				b = abs(b / c) - 1;

				solutions[a][b] = 1;
			}
		}

		m = 0;
		for (j = 0; j < 201; j++)
			for (k = 0; k < 100; k++)
				if (solutions[j][k])
					m++;

		printf("%d\n", m);
	}

	return 0;
}