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. Java并发集合(三)-ConcurrentHashMap分析和使用

    1 http://ifeve.com/hashmap-concurrenthashmap-%E7%9B%B8%E4%BF%A1%E7%9C%8B%E5%AE%8C%E8%BF%99%E7%AF%87% ...

  2. opencv 3.2安装

    opencv 3.2安装 下载地址: https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.2.0/opencv-3.2. ...

  3. Linux_(3)Shell编程(上)

    一.shell 简介Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 既是一种命令语言,又是一种程序设计语言.Shell 是指一种应用程序,这个应用程序提供了一个 ...

  4. Github远程仓库关联

    一.Git的安装 1.git的安装和配置 (1)配置用户名和邮箱,如下所示: $ git config --global user.name [username] $ git config --glo ...

  5. libpcap 库使用(二)

    参考资料: http://www.tcpdump.org/manpages/pcap.3pcap.html 分类介绍了该lib的函数 Opening a capture handle for read ...

  6. 会调色了不起吗? SORRY,会调色真的了不起!

    其实,现实的世界,大部分都是非常普通和常见的.所以调色师才有他们发挥的空间.如何把镜头中的世界变成梦幻一般. 把画面的颜色统一之后,逼格马上提升了很多! 发现表情不对,从其他照片把表情P回来,哈哈 这 ...

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

  8. Ajax原生四大步骤

    1.首先创建一个js文件夹名为common.js.创建一个createXhr()的函数.在此方法中创建异步对象XMLHttpRequest,后面使用的时候直接引入common.js文件,然后进行调用就 ...

  9. tomcat+bean例子

    C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\app\WEB-INF\classes\文件夹下 建立beanTestPa ...

  10. Java第14章笔记

    Java 中无参无返回值和带参带返回值习题 编写一个 Java 程序,实现输出学生年龄的最大值 要求: 1. 要求通过定义无参带返回值的方法来实现,返回值为最大年龄 2. 方法中将​学生年龄保存在数组 ...