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=;
sum+=(a*n);
for(int i=;i<n;i++)
{
sum+=d*i;
}
printf("%d\n",sum);
}
return ;
}
F - Cookies Piles的更多相关文章
- Codeforces Round #530 (Div. 2) F - Cookies
F - Cookies 思路:我们先考虑如何算出在每个节点结束最多能吃多少饼干, 这个dfs的时候用线段树维护一下就好了, 然后有个这个信息之后树上小dp一下就好啦. #include<bits ...
- Codeforces Round #530 (Div. 2)F Cookies (树形dp+线段树)
题:https://codeforces.com/contest/1099/problem/F 题意:给定一个树,每个节点有俩个信息x和t,分别表示这个节点上的饼干个数和先手吃掉这个节点上一个饼干的的 ...
- Codeforces Round #530 (Div. 2) F (树形dp+线段树)
F. Cookies 链接:http://codeforces.com/contest/1099/problem/F 题意: 给你一棵树,树上有n个节点,每个节点上有ai块饼干,在这个节点上的每块饼干 ...
- Codeforces 1099 - A/B/C/D/E/F - (Done)
链接:https://codeforces.com/contest/1099 A - Snowball - [模拟水题] 题意:有一个雪球从山顶滚落,山坡上有两块石头,每秒钟会一次发生三件事:1.雪球 ...
- 用selenium获取cookies
前言:由于登录反爬措施的越来越麻烦,甚至出现了12306这种看图识物的无敌验证码,我只能说,我选择死亡.这就衍生出了使用selenium来获取获取cookies. 实例:获取qq空间cookies,亲 ...
- day95_11_28,selenium定位元素,cookies获取
一.selenium selenium可以将一些资源定位: # 1.find_element_by_id 根据id找 # 2.find_element_by_link_text 根据链接名字找到控件( ...
- 就是这么简单!使用Rest-assured 测试Restful Web Services
使用 Rest-assured 测试 Restful Web Services 转载注明出处: http://www.cnblogs.com/wade-xu/p/4298819.html 这里向大家介 ...
- [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha
Problem B. Cookie Clicker Alpha Introduction Cookie Clicker is a Javascript game by Orteil, where ...
- PHPCMS v9.6.0 wap模块 SQL注入
调试这个漏洞的时候踩了个坑,影响的版本是php5.4以后. 由于漏洞是由parse_str()函数引起的,但是这个函数在gpc开启的时候(也就是php5.4以下)会对单引号进行过滤\' . 看这里: ...
随机推荐
- jsonp,ajax,json问题
JSONP技术 JSONP是解决跨域问题的一种常见方式 跨域问题,因为浏览器有同源策略,所以当不同域间进行数据交互的时候就会出现跨域问题 同源策略:只有在同协议.同域名.同端口的情况下才能进去数据交互 ...
- Python数据库工具类MySQLdb使用
MySQLdb模块用于连接mysql数据库. 基本操作 # -*- coding: utf-8 -*- #mysqldb import time, MySQLdb ...
- Python 使用for...in...和 while 循环 实现8种格式的 九九乘法表
#九九乘法表 for...in .. #左下角 for i in range(1,10): for j in range(1,i+1): print(' %d×%d=%2d'%(j,i,i*j), e ...
- Tgrocery学习及使用
能够学习到短文本分类模型——Tgrocery,十分感谢@GavinBuildSomething把源码及测试数据分享,在此我也作为一名学习者将自己的学习过程记录下来,希望对其他人有所帮助. 1.学习 ...
- SpringMVC 学习 九 SSM环境搭建 (二) Spring配置文件的编写
spring配置文件中需要干的事情 (一)开启 Service与pojo包的注解扫描 注意:spring 扫描与表对应的实体类,以及service层的类,不能用来扫描Controller层的类,因为 ...
- 为什么要选择OMP之合规性
- Python开课复习10
# 储备知识:# 函数的使用应该分为两个明确的阶段# 1. 定义阶段:只检测语法,不执行函数体代码def func(): print('from func')# 2. 调用阶段:会触发函数体代码的执行 ...
- Eclipse中配置约束
一.本地配置schema约束(xsd文件): 1.比如配置spring的applicationContext.xml中的约束条件: 复制applicationContext.xml中如图: 2.win ...
- ODT(old driver tree)详解(带例题)
文章目录 ODT简介 实现前提&&实现原理 初始化 split操作 assign操作 其它操作 区间第k小 区间加 区间所有数的k次方和 几道水题 ODT简介 ODT(old driv ...
- myBatis中if test 字符串注意事项
错误写法: <if test="userName == 'boshen'"> AND `USER_NAME` = #{userName} </if> 正确写 ...