Soldier and Bananas】的更多相关文章

Soldier and Bananas 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=173141 题意: 给出第一个香蕉的价钱k,后买的第i个香蕉所需要的价钱就是i*k: 给出手上所有的钱,求出如果要买w个香蕉还少多少钱. 代码: #include<iostream> using namespace std; int main() { ; cin>>k>>n>>w;…
题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; int main(void) //Codeforces Round #304 (Div. 2) A. Soldier…
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 p…
Problem 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·kdollars for the i-th banana). He has n dollars. How many dollars…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output 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 wor…
  等差数列: 以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+…
题目链接:http://www.codeforces.com/problemset/problem/546/A题意:一个人现在有n元,它买第i根香蕉需要i*k元,问他要买w根香蕉的话,需要问他的朋友借多少钱?C++代码: #include <iostream> using namespace std; int n, k, w; int main() { cin >> k >> n >> w; cout << max(, w*(w+)/*k-n);…
A. Soldier and Bananas   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 d…
之所以在codeforces上找这100道水题的原因是为了巩固我对最近学的编程语言的掌握程度. 找的方式在codeforces上的PROBLEMSET中过的题最多的那些题里面出现的最前面的10个题型,它们是: math(数学) brute force(暴力) strings(字符串) implementation(模拟) greedy(贪心) sortings(排序) number theory(数论) constructive algorithm dp(动态规划) shortest path(…
A. Soldier and Bananas 题意:有个士兵要买w个香蕉,香蕉起步价为k元/个,每多买一个则贵k元.问初始拥有n元的士兵需要借多少钱? 思路:简单题 #include<iostream> #include<cstdio> using namespace std; int main() { int k, n, w; scanf("%d%d%d", &k, &n, &w); + w)*w / ; if (tot <= n…