Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cmath>
- using namespace std;
- struct Point{
- int x;
- int y;
- };
- int main() {
- struct Point points[100];
- int n;
- cin >> n;
- for(int i =0; i < n; i++) {
- cin>>points[i].x;
- cin>>points[i].y;
- }
- float distance = -1;
- int numberOfPoints = 0;
- for(int i =0; i < n; i++) {
- float currentDistance = sqrt((points[i].x -0)*(points[i].x -0) + (points[i].y -0)*(points[i].y -0));
- if(currentDistance > distance) {
- distance = currentDistance;
- numberOfPoints = 1;
- } else if(currentDistance == distance) {
- numberOfPoints++;
- }
- }
- cout << distance << " " << numberOfPoints;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement