好麻烦啊
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
题目背景
这是某条神秘的 if 线上发生的故事。
在这条 if 线上安达也说了“好麻烦啊”,但不是因为岛村知道了安达去了祭典,而是因为岛村不会算四元数。
题目描述
你需要计算四元数乘法。
四元数是这样的一类数:,其中 为四元数单位,他们之间的计算规则符合:
- $\mathbf{ij}=-\mathbf{ji}=\mathbf{k},\mathbf{ki}=-\mathbf{ik}=\mathbf{j},\mathbf{jk}=-\mathbf{kj}=\mathbf{i}$(由此可知四元数单位不符合交换律)
给定两个四元数 $z_1=a_1+b_1\mathbf{i}+c_1\mathbf{j}+d_1\mathbf{k},z_2=a_2+b_2\mathbf{i}+c_2\mathbf{j}+d_2\mathbf{k}$,请计算 $z_1\times z_2=a_3+b_3\mathbf{i}+c_3\mathbf{j}+d_3\mathbf{k}$。
输入格式
八个整数 。
输出格式
四个整数 。
样例输入 1
1 4 2 3 6 4 9 2
样例输出 1
-34 5 25 48
样例解释
展开计算 $(1+4\mathbf{i}+2\mathbf{j}+3\mathbf{k})(6+4\mathbf{i}+9\mathbf{j}+2\mathbf{k})$ 得:
$$\begin{align*} & 1\cdot 6 = 6, \\ & 1\cdot 4\mathbf{i} = 4\mathbf{i}, \\ & 1\cdot 9\mathbf{j} = 9\mathbf{j}, \\ & 1\cdot 2\mathbf{k} = 2\mathbf{k}, \\[4pt] & 4\mathbf{i}\cdot 6 = 24\mathbf{i}, \\ & 4\mathbf{i}\cdot 4\mathbf{i} = 16\mathbf{i}^2 = -16, \\ & 4\mathbf{i}\cdot 9\mathbf{j} = 36\,\mathbf{ij} = 36\mathbf{k}, \\ & 4\mathbf{i}\cdot 2\mathbf{k} = 8\,\mathbf{ik} = 8(-\mathbf{j}) = -8\mathbf{j}, \\[4pt] & 2\mathbf{j}\cdot 6 = 12\mathbf{j}, \\ & 2\mathbf{j}\cdot 4\mathbf{i} = 8\,\mathbf{ji} = 8(-\mathbf{k}) = -8\mathbf{k}, \\ & 2\mathbf{j}\cdot 9\mathbf{j} = 18\,\mathbf{j}^2 = -18, \\ & 2\mathbf{j}\cdot 2\mathbf{k} = 4\,\mathbf{jk} = 4\mathbf{i}, \\[4pt] & 3\mathbf{k}\cdot 6 = 18\mathbf{k}, \\ & 3\mathbf{k}\cdot 4\mathbf{i} = 12\,\mathbf{ki} = 12\mathbf{j}, \\ & 3\mathbf{k}\cdot 9\mathbf{j} = 27\,\mathbf{kj} = 27(-\mathbf{i}) = -27\mathbf{i}, \\ & 3\mathbf{k}\cdot 2\mathbf{k} = 6\,\mathbf{k}^2 = -6. \end{align*}$$合并即得答案为
数据范围
。