Advertisement
LZsolar

SMMR-072: Valentine Plan

Mar 24th, 2020
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. double g1[1010],g2[1010];
  4. double sum = 10000000.0;
  5. int main(){
  6.     int n,m;
  7.     scanf("%d %d",&n,&m);
  8.     for(int i=0;i<n;i++){
  9.         scanf("%lf %lf",&g1[i],&g2[i]);  
  10.     }
  11.     for(int i=0;i<m;i++){
  12.         double a,b;
  13.         scanf("%lf %lf",&a,&b);
  14.        
  15.         for(int j=0;j<n;j++){
  16.             double x=g1[j]-a,y=g2[j]-b;
  17.             double sav = sqrt((x*x)+(y*y));
  18.             if(sav<sum){sum=sav;}
  19.         }
  20.     }
  21.    
  22.     printf("%.3f",sum);
  23.    
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement