列表

详情


NC18999. Relic Discovery

描述

Recently, paleoanthropologists have found historical remains on an island in the Atlantic Ocean. The most inspiring thing is that they excavated in a magnificent cave and found that it was a huge tomb. Inside the construction, researchers identified a large number of skeletons, and funeral objects including stone axe, livestock bones and murals. Now, all items have been sorted, and they can be divided into N types. After they were checked attentively, you are told that there are Ai items of the i-th type. Further more, each item of the i-th type requires Bi million dollars for transportation, analysis, and preservation averagely. As your job, you need to calculate the total expenditure. 

输入描述

The first line of input contains an integer T which is the number of test cases. For each test case, the first line contains an integer N which is the number of types. In the next N lines, the i-th line contains two numbers Ai and Bi as described above. All numbers are positive integers and less than 101.

输出描述

For each case, output one integer, the total expenditure in million dollars.

示例1

输入:

1
2
1 2
3 4

输出:

14

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

pypy3(pypy3.6.1) 解法, 执行用时: 273ms, 内存消耗: 23120K, 提交时间: 2020-06-03 00:50:22

t=int(input())
while(t>0):
    t-=1
    n=int(input());ans=0
    for i in range(n):
        x,y=map(int, input().split())
        ans+=x*y
    print(ans)

Python3(3.5.2) 解法, 执行用时: 55ms, 内存消耗: 3428K, 提交时间: 2020-06-11 10:18:22

t = int(input())
for i in range(0,t):
	n = int(input())
	sum = 0
	for i in range(0,n):
		a, b = map(int, input().split())
		sum += a*b
	print(sum)

上一题