classSolution {
public:int visiblePoints(vector<vector<int>>& points, int angle, vector<int>& location) {
vector<double> angles;
int on =0;
for (constauto& p : points) {
int dy = p[1] - location[1];
int dx = p[0] - location[0];
if (dx ==0&& dy ==0) {
on++;
continue;
}
double ang = atan2(dy, dx) *180/ std::numbers::pi;
if (ang <180+ angle) angles.push_back(ang +360);
angles.push_back(ang);
}
sort(angles.begin(), angles.end());
int left =0, right =0, res =0, n = angles.size();
while (right < n) {
double curr = angles[right++];
while (curr - angles[left] > angle) left++;
res = max(res, right - left);
}
return res + on;
}
};