B. Okabe and Banana Trees
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

The first line of input contains two space-separated integers m and b (1 ≤ m ≤ 1000, 1 ≤ b ≤ 10000).

Output

Print the maximum number of bananas Okabe can get from the trees he cuts.

Examples
input
1 5
output
30
input
2 3
output
25
Note

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) 收藏的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 2014/11/06 Oracle触发器初步 2014-11-06 09:03 49人阅读 评论(0) 收藏

    触发器我就不多解释了,保证数据的完整性的神器,嗯..也是减少程序员工作托管给数据库操作的好帮手.就不讲一些大道理了.通俗点,我们对数据库的操作,无非就是增 删 改 查. 触发器就是在删,改,增的时候( ...

  5. 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 ...

  6. NPOI 通用导出数据到Excel 分类: C# Helper 2014-11-04 16:06 246人阅读 评论(0) 收藏

    应用场景: 在项目中,经常遇到将数据库数据导出到Excel,针对这种情况做了个程序封装.工作原理:利用NPOI将SQL语句查询出的DataTable数据导出到Excel,所见即所得. 程序界面:   ...

  7. jQuery插件treeview点击节点名称不展开、收缩节点 分类: JavaScript 2014-06-16 20:28 539人阅读 评论(0) 收藏

    修改jquery.treeview.js文件中的applyClasses方法(注释掉两行代码): 修改后的applyClasses方法如下: applyClasses: function(settin ...

  8. 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 ...

  9. 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. iOS.CM5.CM4.CM2

    增量数据计算接口: CC_MDx_Init CC_MDx_Update CC_MDx_Final 全量数据计算接口: CC_MDx

  2. 使用Tophat+cufflinks分析差异表达

    使用Tophat+cufflinks分析差异表达  2017-06-15 19:09:43     522     0     0 使用TopHat+Cufflinks的流程图 序列的比对是RNA分析 ...

  3. H5C3动画

    1 渐变 /* 渐变:不同颜色之间的柔和过渡 线性渐变:沿着某条直线发生渐变效果 注意:渐变准备来说是一张背景图 语法:linear-gradient */ background-image: lin ...

  4. c sharp dll

    1. generate dll building .cs file, for example: myDll.cs using System; using System.Collections.Gene ...

  5. 生活类App原型制作分享-AnyList

    AnyList是一款可以帮你创建购物清单,并且帮助你整理食谱的生活工具App,前面引导页采用图片+文字的方式,介绍App的用法,登录注册采用选项卡切换的方式,减少了页面切换的繁琐操作,在Mockplu ...

  6. db2 解锁表

    db2 set integrity for ACT_RU_VARIABLE immediate checked

  7. 【算法】BFS+哈希解决八数码问题

    15拼图已经有超过100年; 即使你不叫这个名字知道的话,你已经看到了.它被构造成具有15滑动砖,每一个从1到15上,并且所有包装成4乘4帧与一个瓦块丢失.让我们把丢失的瓷砖“X”; 拼图的目的是安排 ...

  8. Spring配置ArgumentResolver,统一进行session鉴定

    一.编写WebMvcConfig配置类: 重写addArgumentResolvers方法,将解析类加入 @Configuration public class WebConfig extends W ...

  9. PHP字符串大小写转换函数

    string strtolower(string $str) 将字符串转换为小写 string strtoupper(string $str) 将字符串转换为大写 $str1 = 'html'; $s ...

  10. dblink(转)

    oracle在进行跨库访问时,可以通过创建dblink实现,今天就简单的介绍下如果创建dblink,以及通过dblink完成插入.修改.删除等操作 首先了解下环境:在tnsnames.ora中配置两个 ...