8# Arithmetic Progression等差数列求和

文章目录

问题描述

Since so, arithmetic sequence is completely defined by the first member (A) and the increment value - step size - (B). First few members could be expressed as

A + (A + B) + (A + 2B) + (A + 3B) + …
You are to calculate the sum of first members of arithmetic sequence. Wikipedia page on arithmetic progression could be of significant help to one who meets them for the first time.

Input data: first line contains the number of test-cases.
Other lines contain test-cases in form of triplets of values A B N where A is the first value of the sequence, B is the step size and N is the number of first values which should be accounted.
Answer: you are to output results (sums of N first members) for each sequence, separated by spaces.
第一个数是初始数,第二个是步长,第三个是数字个数,求和。
Example:
在这里插入图片描述

代码

num=input()
for i in range(int(num)):
    a=list(map(int,input().split()))
    result=round((a[0]+a[0]+a[1]*(a[2]-1))*a[2]/2)
    print(result,end=" ")

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值