等差数列: 以k为首相,k为公差,w个数量的和与n的大小关系 输出max(sum-0,0)

Java程序

 

import java.util.Scanner;

public class A546 {

    static void run(){
Scanner in = new Scanner(System.in);
int k =in.nextInt();
int n = in.nextInt();
int w = in.nextInt();
int count = 0;
count = (1+w)*w*k/2;
// System.out.println(count);
if(count>n){
System.out.println(count-n);
}else
System.out.println(0);
}
public static void main(String[] args){
run();
}
}

Python程序

def A546():
k,n,w = map(int, raw_input().split())
count = (1+w)*w*k*0.5
if count > n :
print int(count -n)
else:
print 0 if __name__=='__main__':
A546()

546A. Soldier and Bananas的更多相关文章

  1. Soldier and Bananas

    Soldier and Bananas 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=173141 题意: 给 ...

  2. 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas

    题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...

  3. 【codeforces 546A】Soldier and Bananas

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. A - Soldier and Bananas

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

  5. B - Soldier and Bananas

    Problem description A soldier wants to buy w bananas in the shop. He has to pay k dollars for the fi ...

  6. codeforces水题100道 第五题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas (math)

    题目链接:http://www.codeforces.com/problemset/problem/546/A题意:一个人现在有n元,它买第i根香蕉需要i*k元,问他要买w根香蕉的话,需要问他的朋友借 ...

  7. Codeforces Round #304 (Div. 2) -----CF546

    A. Soldier and Bananas   A soldier wants to buy w bananas in the shop. He has to pay k dollars for t ...

  8. codeforcess水题100道

    之所以在codeforces上找这100道水题的原因是为了巩固我对最近学的编程语言的掌握程度. 找的方式在codeforces上的PROBLEMSET中过的题最多的那些题里面出现的最前面的10个题型, ...

  9. Codeforces Round #304 (Div.2)

    A. Soldier and Bananas 题意:有个士兵要买w个香蕉,香蕉起步价为k元/个,每多买一个则贵k元.问初始拥有n元的士兵需要借多少钱? 思路:简单题 #include<iostr ...

随机推荐

  1. [转]Asp.net三种事务处理

    事务处理是在数据处理时经常遇到的问题,经常用到的方法有以下三种总结整理如下:方法1:直接写入到sql 中在存储过程中使用 BEGIN TRANS, COMMIT TRANS, ROLLBACK TRA ...

  2. C++ MFC实现基于RFID读写器的上位机软件

    C++ MFC实现基于RFID读写器的上位机软件 该博客涉及的完整工程托管在https://github.com/Wsine/UpperMonitor,觉得好请给个Star (/▽\=) 运行和测试环 ...

  3. Oracle无法drop用户,提示有连接不能删除时

    百度了一下,这个可以行得通 select username,sid,serial# from v$session alter system kill SESSION '133,169' ; drop ...

  4. c语言参数类型

    今天看ntcip源码时看到,函数参数有点不一样.在函数实现时,没有括号中没有指明参数类型.注意这里说的是函数实现,不是说函数声明.这里在函数列表括号后面做了类型的说明,以前看到过,没想起来,今天做个记 ...

  5. PSP0表格

    一 项目计划日志 周活动总结表 姓名:陆宇                                                                         日期:3.1 ...

  6. htop

    apt-get install htop

  7. 关于ASCII、GB231、GBK、UTF-8/UTF8、ANSI、unicode的学习笔记

    继续上次的学习内容,写一些自己学习的笔记吧!总是觉得没有笔记的学习总是不那么踏实,我承认自己是个记忆力很差的人,特别羡慕那些可以把自己学过的东西记得很牢靠的人.哎!可惜我不是,那只能做出来点东西,就算 ...

  8. Careercup - Microsoft面试题 - 5673934611546112

    2014-05-10 23:26 题目链接 原题: what is the best,worst and average case complexity for fibonacci no.s ..ex ...

  9. Careercup - Google面试题 - 5727310284062720

    2014-05-06 14:04 题目链接 原题: given an 2D matrix M, is filled either using X or O, you need to find the ...

  10. 【Binary Tree Zigzag Level Order Traversal】cpp

    题目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from lef ...