Codeforces821B Okabe and Banana Trees 2017-06-28 15:18 25人阅读 评论(0) 收藏
2 seconds
256 megabytes
standard input
standard output
Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.
Consider the point (x, y) in the 2D plane such that x and y are
integers and 0 ≤ x, y. There is a tree in such a point, and it has x + ybananas.
There are no trees nor bananas in other points. Now, Okabe draws a line with equation
.
Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it
can be a line segment or even a point.
Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely.
Okabe is sure that the answer does not exceed 1018.
You can trust him.
The first line of input contains two space-separated integers m and b (1 ≤ m ≤ 1000, 1 ≤ b ≤ 10000).
Print the maximum number of bananas Okabe can get from the trees he cuts.
1 5
30
2 3
25

The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.
——————————————————————————————————————
题目的意思是给出一条斜线,在第一象限的斜线(可以轴上)上取一个点,它与原点形
成一个矩阵 每个点的值为横纵坐标之和,问矩阵内(上)所有点之和最大多少
思路:每一行各点之和是等差数列,矩阵中上一列比下一列的每个数大1 数学统计即可
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits> using namespace std; #define LL long long
const int INF = 0x3f3f3f3f; int main()
{
LL m,n;
while(~scanf("%lld%lld",&m,&n))
{
LL mx=-1;
for(int i=0;i<=n;i++)
{
LL x=((n-i)*m*((n-i)*m+1)/2)*(i+1)+((n-i)*m+1)*(1+i)*i/2;
mx=max(x,mx);
}
printf("%lld\n",mx); }
return 0;
}
Codeforces821B Okabe and Banana Trees 2017-06-28 15:18 25人阅读 评论(0) 收藏的更多相关文章
- Codeforces821C Okabe and Boxes 2017-06-28 15:24 35人阅读 评论(0) 收藏
C. Okabe and Boxes time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Codeforces821A Okabe and Future Gadget Laboratory 2017-06-28 14:55 80人阅读 评论(0) 收藏
A. Okabe and Future Gadget Laboratory time limit per test 2 seconds memory limit per test 256 megaby ...
- Hdu2841 Visible Trees 2017-06-27 22:13 24人阅读 评论(0) 收藏
Visible Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- 2014/11/06 Oracle触发器初步 2014-11-06 09:03 49人阅读 评论(0) 收藏
触发器我就不多解释了,保证数据的完整性的神器,嗯..也是减少程序员工作托管给数据库操作的好帮手.就不讲一些大道理了.通俗点,我们对数据库的操作,无非就是增 删 改 查. 触发器就是在删,改,增的时候( ...
- The Managed Metadata Service or Connection is currently not available 分类: Sharepoint 2015-07-09 13:28 5人阅读 评论(0) 收藏
Does the following error message looks familiar to you? (When you go to Site Actions –> Site Sett ...
- NPOI 通用导出数据到Excel 分类: C# Helper 2014-11-04 16:06 246人阅读 评论(0) 收藏
应用场景: 在项目中,经常遇到将数据库数据导出到Excel,针对这种情况做了个程序封装.工作原理:利用NPOI将SQL语句查询出的DataTable数据导出到Excel,所见即所得. 程序界面: ...
- jQuery插件treeview点击节点名称不展开、收缩节点 分类: JavaScript 2014-06-16 20:28 539人阅读 评论(0) 收藏
修改jquery.treeview.js文件中的applyClasses方法(注释掉两行代码): 修改后的applyClasses方法如下: applyClasses: function(settin ...
- cloud theory is a failure? 分类: Cloud Computing 2013-12-26 06:52 269人阅读 评论(0) 收藏
since LTE came out, with thin client cloud computing and broadband communication clouding 不攻自破了.but ...
- A simple problem 分类: 哈希 HDU 2015-08-06 08:06 1人阅读 评论(0) 收藏
A simple problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
随机推荐
- 1.maven安装配置
这段时间在做项目构建管理方面的工作,以前很多项目都是通过ant去构建的,虽然很早就接触过mavan,但是从没有系统的去学习过, 现在项目需要用maven来构建,我结合自己的心得整理一下放在博客上作为自 ...
- c#devexpress GridContorl datasource为 类字段的实现方式 非datatable方式以及其他操作总结
1:定义model class A { public string a{get;set;} public string b{get;set;} } 2:赋值: A aobj=new A(); aobj ...
- mybatis入门--mybatis和hibernate比较
mybatis和hibernate的比较 Mybatis和hibernate不同,它不完全是一个ORM框架,因为MyBatis需要程序员自己编写Sql语句,不过mybatis可以通过XML或注解方式灵 ...
- JS-事件心得
写在前面的话:就我目前的水平来看,这两种方法不能一起使用,用on添加的事件removeEventListener()没办法删除,反之一样 注册事件的两种方式: on+事件名称 addEventList ...
- gcd(欧几里得算法)
基础 int gcd(int a,int b) { int r; ) { r=a%b; a=b; ...
- BZOJ1912或洛谷3629 [APIO2010]巡逻
一道树的直径 BZOJ原题链接 洛谷原题链接 显然在原图上路线的总长为\(2(n-1)\). 添加第一条边时,显然会形成一个环,而这条环上的所有边全部只需要走一遍.所以为了使添加的边的贡献最大化,我们 ...
- linux- Fedora25 下 解决anacondas3 与ibus冲突问题
问题:当我们安装了anaconda3之后,会发现ibus-setup进不去. 原因: 是因为ibus-setup的python应该使用python2. 而当我们安装了anaconda3之后,调用pyt ...
- vue 浏览器页面刷新时执行一段代码
当刷新(浏览器刷新)页面的时候,重置到首页(或其他页面)纯js的是window.onload()但是vue几乎不会用到这个,vue所有的是生命周期那么我们可以根据生命周期来实现这个beforeCrea ...
- JDK8集合类源码解析 - LinkedList
linkedList主要要注意以下几点: 1构造器 2 添加add(E e) 3 获取get(int index) 4 删除 remove(E e),remove(int index) 5 判断对象 ...
- mysql.lib 的使用
一 说明 mysql.lib 提供了很多方便的操作,同时结合 vector 使用十分方便. 二 使用 1 声明需要用到的变量 static MYSQL s_mysql[DATABASE ...