Codeforces821B Okabe and Banana Trees
来源:互联网 发布:西南大学网络教育2017 编辑:程序博客网 时间:2024/06/07 10:58
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 longconst 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
- CF821B-Okabe and Banana Trees
- Okabe and Banana Trees CodeForces
- Codeforces 821 B. Okabe and Banana Trees
- codeforces 821 B Okabe and Banana Trees
- Codeforces 821B-Okabe and Banana Trees
- Codeforces#420 Okabe and Banana Trees
- CF #420 B. Okabe and Banana Trees
- codeforces -420-B. Okabe and Banana Trees
- Okabe and Banana Trees 思路题
- #420 B. Okabe and Banana Trees(Div.2)
- Codeforces Round #420 (Div. 2) B. Okabe and Banana Trees
- Codeforces 821B Okabe and Banana Trees 题解
- Codefroces 821B Okabe and Banana Trees(暴力)
- Codeforces Round #420 B. Okabe and Banana Trees
- CF#420 B. Okabe and Banana Trees 思维|暴力|几何
- #420 Div.2 B. Okabe and Banana Trees——数学&暴力
- CF#420 Div.2 B. Okabe and Banana Trees(数学)
- js面向过程的选项卡
- 补6/27
- EditText不自动弹出键盘,界面退出隐藏键盘
- 【C/C++】链表的理解与使用
- leveldb(一):AtomicPointer
- Codeforces821B Okabe and Banana Trees
- placeholder兼容ie和password
- 用于正则表达式模式匹配的String方法
- 大家好,我是黑客H,我为M高校的网络安全带盐!
- 金山词霸每日一句
- java mongodb aggregate用法
- 关于sublime text3乱码问题
- 十五分钟介绍 Redis数据结构
- [我的作死案例]图书馆泡妹记 上