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以下)会对单引号进行过滤\' . 看这里: ...
随机推荐
- iOS常用代码总结
1.读取图片NSString *path = [[NSBundle mainBundle] pathForResource"icon" ofType"png"] ...
- Windows cordova build Error: Could not find gradle wrapper within Android SDK.(转)
原文:http://blog.csdn.net/kongxx/article/details/68954151 在Windows7上运行 “cordova build Android” 报错,如下: ...
- tp5查看版本
5.0 base.php 5.1 echo \think\facade\App::version();//用这行代码查看版本
- list,set等集合遍历时,不能remove集合中的元素。需要new一个Object或者list,set,里面add需要删除的元素,等集合遍历完了进行remove(Object)或者removeAll(list/set)操作
list,set等集合遍历时,不能remove集合中的元素.需要new一个Object或者list,set,里面add需要删除的元素,等集合遍历完了进行remove(Object)或者removeAl ...
- How-to Install VMware Tools on Debian Stretch 9 32/64bit Linux+GNU
在虚拟机VMWARE上安装debian9 安装vmwaretools时候遇到问题 询问我IFCONFIG安装在哪里? 新版的debian不知道是用户权限问题还是使用了其他网络配置工具 vmwareto ...
- Nginx+Tomcat安装与配置(windows版)
相信很多人都听过nginx,这个小巧的东西慢慢地在吞食apache和IIS的份额.那究竟它有什么作用呢?可能很多人未必了解. 说到反向代理,可能很多人都听说,但具体什么是反向代理,很多人估计就不清楚了 ...
- m序列生成电路
m序列
- Angular学习笔记:Angular CLI
定义 Angular CLI:The Angular CLI is a command line interface tool that can create a project, add files ...
- MySQL数据库innodb_rollback_on_timeout默认值的危害?
http://www.ywnds.com/?p=9560 一.innodb_rollback_on_timeout变量 有时侯会发生事务超时的情况,MySQL会返回类似这样的错误: 1 ERROR ...
- 41.App 框架的搭建思路以及代码的规范
本链接 引用别人文章https://www.jianshu.com/p/d553096914ff