Last active
October 8, 2016 20:27
-
-
Save krofna/75c39f752874c97130c9af4b4af6cd02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
#include <cstdint> | |
using namespace std; | |
int CX[200], CY[200], BX[200], BY[200]; | |
int N, M; | |
int maxt = 0; | |
bool CheckPoint(int64_t A, int64_t B, int64_t C, int64_t D, int64_t x, int64_t y) | |
{ | |
int64_t f = A * (x * x + y * y) + B * x + C * y + D; | |
return ((A > 0) ? f <= 0 : f >= 0); | |
} | |
int64_t Determinanta(int64_t* A, int64_t* B, int64_t* C) | |
{ | |
return A[0] * B[1] * C[2] + | |
B[0] * C[1] * A[2] + | |
C[0] * A[1] * B[2] - | |
A[0] * C[1] * B[2] - | |
B[0] * A[1] * C[2] - | |
C[0] * B[1] * A[2]; | |
} | |
void RijesiKruznicu(int i, int j, int k) | |
{ | |
int64_t M0[3], M1[3], M2[3], M3[3]; | |
M0[0] = CX[i] * CX[i] + CY[i] * CY[i]; | |
M0[1] = CX[j] * CX[j] + CY[j] * CY[j]; | |
M0[2] = CX[k] * CX[k] + CY[k] * CY[k]; | |
M1[0] = CX[i]; | |
M1[1] = CX[j]; | |
M1[2] = CX[k]; | |
M2[0] = CY[i]; | |
M2[1] = CY[j]; | |
M2[2] = CY[k]; | |
M3[0] = 1; | |
M3[1] = 1; | |
M3[2] = 1; | |
int64_t A = Determinanta(M1, M2, M3); | |
if (!A) | |
return; | |
int64_t B = -Determinanta(M0, M2, M3); | |
int64_t C = Determinanta(M0, M1, M3); | |
int64_t D = -Determinanta(M0, M1, M2); | |
int num = 0; | |
for (int i = 0; i < M; ++i) | |
if (CheckPoint(A, B, C, D, BX[i], BY[i])) | |
++num; | |
if (num > maxt) | |
maxt = num; | |
} | |
int main() | |
{ | |
cin >> N; | |
for (int i = 0; i < N; ++i) | |
cin >> CX[i] >> CY[i]; | |
cin >> M; | |
for (int i = 0; i < M; ++i) | |
cin >> BX[i] >> BY[i]; | |
for (int i = 0; i < N; ++i) | |
for (int j = i + 1; j < N; ++j) | |
for (int k = j + 1; k < N; ++k) | |
RijesiKruznicu(i, j, k); | |
cout << maxt << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment