CodeForces 546A-Soldier and Bananas】的更多相关文章

  等差数列: 以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+…
题目传送门 /* 水题: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…
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;…
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…
题目链接: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);…
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…
题目描述: Soldier and Number Game time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to t…
题目大概说一张无向图,各个结点初始有ai人,现在每个人可以选择停留在原地或者移动到相邻的结点,问能否使各个结点的人数变为bi人. 如此建容量网络: 图上各个结点拆成两点i.i' 源点向i点连容量ai的边 i'向汇点连容量bi的边 i向i'连容量INF的边 对于相邻的两点(u,v),u向v'连容量INF的边,v'向u连容量INF的边 跑最大流看看最大流是否等于∑bi.另外,注意∑ai不等于∑bi的情况. #include<cstdio> #include<cstring> #incl…
题目链接 给出n个城市, 以及初始时每个城市的人数以及目标人数.初始时有些城市是相连的. 每个城市的人只可以待在自己的城市或走到与他相邻的城市, 相邻, 相当于只能走一条路. 如果目标状态不可达, 输出no, 否则输出每个城市的人都是怎么走的, 比如第一个城市有2个人走到了第二个城市, 1个人留在了第一个城市, 那么输出的第一行前两个数就是1, 2. 很明显的网络流, 输出那里写了好久... 首先判断能否可达, 如果初始状态的人数与目标状态不一样, 一定不可达, 其次, 如果建完图跑网络流的结果…