浙大五月月赛E:P-norm(输入处理)

 

P-norm
Time Limit: 2 Seconds       Memory Limit: 65536 KB       Special Judge

In mathematics, the complex numbers are the extension of the real numbers obtained by adjoining an imaginary unit, denoted i, which satisfies: i2=-1. Every complex number can be written in the form a + bi or (a, b), where a and b are real numbers called the real part and the imaginary part of the complex number, respectively. The absolute value (or modulus or magnitude) of a complex number x = a + bi is defined as |x| = sqrt(a2 + b2).

In linear algebra, functional analysis and related areas of mathematics, a norm is a function that assigns a strictly positive length or size to all vectors in a vector space, other than the zero vector. P-norm is the most frequently used norm, let p >= 1 be a real number, x = (x1 x2 ... xn)T||x||p = (|x1|p + |x2|p + ... + |xn|p)1/p.

Given two vectors x and y in vector space over complex numbers, you job is to calculate ||x - y||p.

Input

Two vectors in vector space over complex number. The complexs are in notation (Re,Im), and the vectors are in form "x1 x2 ... xn" in a seperate line where 1 <= n <= 16 is the dimension of the vector and both a and b in xk = a + bi are in range [-16, 16]. Then a real number p specifies which p-norm we will use, p is in range [1, 16].

Each line contains no more than 256 characters, and the blanks only occur between adjacent complexes.

Output

A number: ||x - y||p. All answers with either an absolute or relative error of less than 1e-6 are considered correct.

Sample Input

(4,0) (0,0)
(0,0) (0,-3)
2
(1,0) (0,1) (-1,0) (0,-1)
(1,0) (0,-1) (-1,0) (0,1)
1
(1.4142135623730950488016887242097,-1.4142135623730950488016887242097)
(0,0)
3.1415926535897932384626433832795
(1,1)
(0,0)
2.7182818284590452353602874713527

Sample Output

5
4
2
1.4142135623730950488016887242097
题意:
思路:
        题目看懂就不难了,问题是题目看不懂!
学习点:输入处理。
           1、sscanf
           2、。。。
源代码(参考):
一、sscanf,更倾向于这种。
 
二、
 
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值