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

建议使用的浏览器:

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

3568:Help Johnny

题目描述
Poor Johnny is so busy this term. His tutor threw lots of hard problems to him and demanded him to accomplish those problems in a month. What a wicked tutor! After cursing his tutor thousands of times, Johnny realized that he must start his work immediately.
The very problem Johnny should solve firstly is about a strange machine called Warmouth. In the Warmouth there are many pairs of balls. Each pair consists of a red ball and a blue ball and each ball is assigned a value. We can represent a pair in the form of (R, B) in which R is the value of the red ball and B is of the blue one. The match value of (R1, B1) and (R2, B2) is R1*B2+R2*B1. Warmouth has a generator to calculate the match value of two pairs. Initially, Warmouth is empty. Pairs are sent into Warmouth in order. Once a new pair comes, it will be taken into the generator with all the pairs already in Warmouth.
Johnny’s work is to tell his tutor the sum of all match values given the list of pairs in order. As the best friend of Johnny, would you like to help him?
输入解释
The first line of the input is T (no more than 10), which stands for the number of lists Johnny received.
Each list begins with “N“(without quotes). N is the number of pairs of this list and is no more than 100000.
The next line gives N pairs in chronological order. The 2i-th number is the value of the red ball of the i-th pair and the (2i+1)-th number is the value of the blue ball of the i-th pair. The numbers are positive integers and smaller than 100000.
输出解释
Please output the result in a single line for each list in the format of "Case x: d", in which x is the case number counted from one and d is the sum. The result is guaranteed to be smaller than 2^63.
输入样例
2
3
1 3 2 2 3 1
2
4 5 6 7
输出样例
Case 1: 26
Case 2: 58
来自杭电HDUOJ的附加信息
Author zhymaoiing
Recommend zhouzeyong

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3568

最后修改于 2020-10-25T23:04:50+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/32768K(Java/Others)