fork download
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4. using namespace std;
  5. void Nhap(int M[], int n)
  6. {
  7. for (int i=0; i< n; i++)
  8. {
  9. cin>>M[i];
  10. }
  11. }
  12. float Tinh(int M[], int N[], int n)
  13. {
  14. float d=0;
  15. for(int i=0; i<n; i++)
  16. {
  17. d=d+pow((N[i]-M[i]), 2);
  18. }
  19. return sqrt(d);
  20. }
  21. int main()
  22. {
  23. int n;
  24. cin>>n;
  25. int M[100], N[100];
  26. Nhap(M, n);
  27. Nhap(N,n);
  28. float kq=Tinh(M, N, n);
  29. cout<<fixed<<setprecision(5)<<kq;
  30. return 0;
  31. }
Success #stdin #stdout 0s 4532KB
stdin
43
56 247 71 38 602 385 728 742 712 466 913 781 80 675 250 342 258 792 128 201 528 441 673 328 43 482 54 267 783 664 449 196 352 166 749 251 191 132 306 963 681 650 876 
150 480 391 87 276 558 891 879 310 531 565 644 858 613 208 830 949 969 742 165 832 463 40 459 47 223 65 398 778 529 94 797 470 440 368 83 191 113 80 209 662 442 75 
stdout
2249.32837