Language: C++

/**
 * ??????????????????????????¢

???????????????????????????????????????????????????????????????????????¢??§??¬???????????????????????????????????°???????????????????§?????????¨????????§????????????????????????????????§??????????????? n ?¬???????????????? x={x1,x2,...,xn} ??¨ y={y1,y2,...,yn} ????????¢????¨????????????????????????????

????????????????????????????????¢?????¬???????¨?????????¨?????¨??????????¬??????????????????????????????¢?????\?????????????????????
Dxy=(???i=1n|xi???yi|p)1p


p=1 ?????¨???

Dxy=|x1???y1|+|x2???y2|+...+|xn???yn|

??¨?????????????????????????????????????????¢??¨?????°????????????

p=2 ?????¨???

Dxy=(|x1???y1|)2+(|x2???y2|)2+...+(|xn???yn|)2???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??¨???????????????????????¬?????????????????????????????????????????¢??????????????????

p=??? ?????¨???

Dxy=maxni=1(|xi???yi|)

??¨???????????????????????§????????§????????¢??¨?????°????????????

????????? n ?¬???????????????????????????????????????§???p ??????????????? 1???2???3?????? ?????????????????????????????¢????±???????????????°????????????????????????????????????

Input
??????????????´??° n ???????????????????????????????????????????????? x ???????´? {x1,x2,...xn}??????????????????????????? y ???????´? {y1,y2,...yn} ????????????????????§???????????????????????\?????????????????´??°?????§??????

Output
p ??????????????? 1???2???3?????? ??????????????????????????????????????¢??????????????????????????????????????????0.00001 ??\????????????????????£????????????????????¨????????????

Constraints
1???n???100
0???xi,yi???1000

Sample Input
3
1 2 3
2 0 4
Sample Output
4.000000
2.449490
2.154435
2.000000
 */

#include <iostream>
#include <sstream>
#include <valarray>
#include <iomanip>

int main(int argc, char const *argv[]) {
  std::string Param;
  std::istringstream iss;
  unsigned short n;
  double Manhattan, Euclidean, Chebyshev, D;

  getline(std::cin, Param);
  iss.str(Param);
  iss >> n;
  iss.clear();

  std::valarray<double> x((short)0, n);
  std::valarray<double> y((short)0, n);

  getline(std::cin, Param);
  iss.str(Param);
  for (size_t i = 0; i < n; i++) {
    int xi = 0;
    iss >> xi;
    x[i] = xi;
  }
  iss.clear();

  getline(std::cin, Param);
  iss.str(Param);
  for (size_t i = 0; i < n; i++) {
    int yi = 0;
    iss >> yi;
    y[i] = yi;
  }
  iss.clear();

  Manhattan = abs(x - y).sum();
  Euclidean = sqrt(pow(abs(x - y), 2.0).sum());
  D = cbrt(pow(abs(x - y), 3.0).sum());
  Chebyshev = abs(x - y).max();

  std::cout << std::fixed << std::setprecision(8);
  std::cout << Manhattan << std::endl;
  std::cout << Euclidean << std::endl;
  std::cout << D << std::endl;
  std::cout << Chebyshev << std::endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:67:38: error: call of overloaded 'valarray(short int, short unsigned int&)' is ambiguous
   67 |   std::valarray<double> x((short)0, n);
      |                                      ^
In file included from a.cc:53:
/usr/include/c++/14/valarray:639:5: note: candidate: 'std::valarray<_Tp>::valarray(const _Tp*, std::size_t) [with _Tp = double; std::size_t = long unsigned int]'
  639 |     valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/valarray:633:5: note: candidate: 'std::valarray<_Tp>::valarray(const _Tp&, std::size_t) [with _Tp = double; std::size_t = long unsigned int]'
  633 |     valarray<_Tp>::valarray(const _Tp& __t, size_t __n)
      |     ^~~~~~~~~~~~~
a.cc:68:38: error: call of overloaded 'valarray(short int, short unsigned int&)' is ambiguous
   68 |   std::valarray<double> y((short)0, n);
      |                                      ^
/usr/include/c++/14/valarray:639:5: note: candidate: 'std::valarray<_Tp>::valarray(const _Tp*, std::size_t) [with _Tp = double; std::size_t = long unsigned int]'
  639 |     valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/valarray:633:5: note: candidate: 'std::valarray<_Tp>::valarray(const _Tp&, std::size_t) [with _Tp = double; std::size_t = long unsigned int]'
  633 |     valarray<_Tp>::valarray(const _Tp& __t, size_t __n)
      |     ^~~~~~~~~~~~~