F - Cookies Piles

Description

The kids in my son's kindergarten made Christmas cookies with their teacher, and piled them up in columns.  They then arranged the columns so that the tops of the columns, going from shortest to tallest, were in a nice straight ramp.  The cookies were all of uniform size.  Given that there were A cookies in the shortest pile, that the difference in height between any two adjacent piles was D cookies, and that there were N piles, can you write a program to figure out how many cookies there were in total?
 
INPUT
The first line contains the number of test cases T. T lines follow, one corresponding to each test case, containing 3 integers : N, A and D.
 
OUTPUT
Output T lines, each line containing the required answer for the corresponding test case.
 
CONSTRAINTS
T <= 100
1 <= N, A, D <=100
 
SAMPLE INPUT
3
1 1 1
3 5 6
2 1 2
 
SAMPLE OUTPUT
1
33
4
 
EXPLANATION
In the second test case the sequence is: 5, 11, 17 whose sum is 33.

 

题意: n   a   d   大概就是n个盘子  默认从小到大排序   最小的里面放了a个东西   从最小到最大一次增加d个物品     求全部盘子里的全部物品

         5+(5+6)+((5+6)+6)   ==   33

 

 #include <iostream>
 #include <string.h>
 #include <stdio.h>

 using namespace std;

 int main()
 {
     int n,a,d;
     int t;
     scanf("%d",&t);
     while(t--)
     {
         scanf("%d%d%d",&n,&a,&d);
         int sum=0;
         sum+=(a*n);
         for(int i=0;i<n;i++)
         {
             sum+=d*i;
         }
         printf("%d\n",sum);
     }
     return 0;
 }

 

转载于:https://www.cnblogs.com/zhangying/p/3924153.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值