Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana).

He has n dollars. How many dollars does he have to borrow from his friend soldier to buy w bananas?

Input

The first line contains three positive integers k, n, w (1  ≤  k, w  ≤  1000, 0 ≤ n ≤ 109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants.

Output

Output one integer — the amount of dollars that the soldier must borrow from his friend. If he doesn't have to borrow money, output 0.

Sample Input

Input
3 17 4
Output
13

题意:

士兵去买香蕉,买的第一根香蕉的价格为k,第i根的价格为i*k。给定士兵带的钱和需要买的香蕉数目,求士兵要借多少钱,如果不用借钱,则输出0.(由于没有判断输出0的条件WA了一发..冤枉啊!!!!!)

虽然是一道水题,但还是发出来劝解各位小伙伴和自己一定要认真读题,千万不要冤WA。

还是附AC代码:

 #include<iostream>
using namespace std; int a[]; int main(){
int k,n,w,sum=;
cin>>k>>n>>w;
for(int i=;i<=w;i++){
a[i]=i*k;
sum+=a[i];
}
if(sum-n>)//!!!!!!
cout<<sum-n<<endl;
else
cout<<""<<endl;
return ;
}

最新文章

  1. C#委托和事件
  2. MATLAB 文件对话框之图片格式转换
  3. C语言修炼-第2天
  4. hdu 2018 母牛的故事
  5. Drupal8开发教程:认识.info.yml文件
  6. 关于Failed to convert property value of type [org.quartz.impl.StdScheduler] to required type [org.springframework.scheduling.quartz.SchedulerFactoryBean
  7. IOS8开发之实现App消息推送
  8. ASP.NET常用导出Excel方法汇总
  9. c++之 数组
  10. [Echarts]用Echarts绘制饼状图
  11. 1687: [Usaco2005 Open]Navigating the City 城市交通
  12. HTML解析器BeautifulSoup
  13. 边看MHA源码边学Perl语言之一开篇
  14. [ACdream]小晴天老师系列——竖式乘
  15. python读写word、excel、csv、json文件
  16. 01——Solr学习之全文检索服务系统的基础认识
  17. Partition--使用分区切换来增加修改列的自增属性
  18. windows上apache是线程处理请求,linux上apache是进程处理请求
  19. WPF中使用WindowChrome美化窗口过程中的一个小问题
  20. August 01st 2017 Week 31st Tuesday

热门文章

  1. 使用母版页时内容页如何使用css和javascript
  2. 第三讲_图像特征与描述Image Feature Descriptor
  3. 零售连锁行业SOA化解决方式
  4. RBtree插入跟删除图解代码
  5. Serial attached SCSI
  6. webpack打包报错Unexpected token
  7. 云打印-Beta-凡事预则立
  8. hihocode #1388 : Periodic Signal NTT
  9. enumerated types
  10. Netty实现时间服务演示样例