当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3244:Difference between Triplets

题目描述

For every pair of triplets, Ta = (Ia, Ja, Ka) and Tb = (Ib, Jb, Kb), we define the difference value between Ta and Tb as follows:

D(Ta, Tb) = max {Ia Ib, JaJb, KaKb} − min {Ia Ib, JaJb, KaKb}

Now you are given N triplets, could you write a program to calculate the sum of the difference values between every unordered pair of triplets?
输入解释
The input consists of several test cases.
Each test case begins with a line containing an integer N, denotes the number of triplets. Assume that we number the triplets as T1, T2, ... , TN. Then, there are following N lines, each line contains three integers, giving the elements of each triplet.
A case with N = 0 indicates the end of the input.
输出解释
For each case, output a line with the sum of difference values between every unordered pair of triplets.
输入样例
2
1 2 3
3 2 1
3
1 3 2
4 0 7
2 2 9
0
输出样例
4
20
提示
Case 1: D(T1,T2)=4
Case 2: D(T1,T2)+D(T1,T3)+D(T2,T3)=8+8+4=20

You can assume that N, the number of triplets in each case, will not exceed 200,000 and the elements in triplets fit into [-106,106].
The size of the input will not exceed 5 MB.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3244

最后修改于 2020-10-29T06:56:42+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 65536