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 ...
随机推荐
- hdu 1754(基础线段树) I Hate It
http://acm.hdu.edu.cn/showproblem.php?pid=1754 数据比较大,暴力会超时,所以明显是线段树,普通的线段树,结构体中多开一个值sum储存每个子区间的最大成绩, ...
- BZOJ 3131 [SDOI2013]淘金 - 数位DP
传送门 Solution 这道数位$DP$看的我很懵逼啊... 首先我们肯定要先预处理出 $12$位乘起来的所有的可能情况, 记录入数组 $b$, 发现个数并不多, 仅$1e4$不到. 然后我们考虑算 ...
- sscanf 解析字符串
test.txt中内容如下所示: eth0||192.168.0.2-192.168.0.150 eth2||192.168.0.2-192.168.0.150 想要将其中的ip地址等解析出来: #i ...
- Writing modular applications with laravel-modules
01-07-2016 Let me start by saying Laravel is an amazing framework. However when it comes to writing ...
- win10无法访问别的机器的共享目录
Win + R 输入 regedit Open Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstat ...
- Vue 汇总
1.右键菜单(防止默认行为) @contextmenu.native.prevent="rightClick()"
- SQL将完整时间字段截取到年月日
在SQL查询语句中使用convert(char(10),日期字段,120)方法 1.char(10)指'yyyy-mm-dd'正好10个字符 2.120的是日期的格式 3.使用语句:select * ...
- SpringBoot注册Servlet/Filter/Listener
由于SpringBoot默认是以jar包的方式启动嵌入式的Servlet容器来启动SpringBoot的web应用,那么没有web.xml文件,如何配置我们的三大Web基础组件呢? 通过使用XXXRe ...
- 【Java】使用Apache POI生成和解析Excel文件
概述 Excel是我们平时工作中比较常用的用于存储二维表数据的,JAVA也可以直接对Excel进行操作,分别有jxl和poi,2种方式. HSSF is the POI Project's pure ...
- 各种 on事件触发js代码
[转]各种 on事件触发js代码 1.onmouseenter:当鼠标进入选区执行代码 <div style="background-color:red" onmouseen ...