Okabe and Banana Trees 思路题
来源:互联网 发布:淘宝 延长收货 几天 编辑:程序博客网 时间:2024/05/29 17:38
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 thatx and y are integers and0 ≤ x, y. There is a tree in such a point, and it hasx + y bananas. 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 has30 bananas.
#include<stdio.h>int main(){ long long int m,b,x; long long int max,count; int i,j; while(scanf("%lld %lld",&m,&b)!=EOF) { max=0; for(i=b;i>=0;i--)//遍历y 此时求得的x一定是一个整数 { count=0; x=(b-i)*m; count=(1+i)*i/2*(x+1)+(1+x)*x/2*(i+1);//求数量用等差数列前n项和 if(count>max) max=count; } printf("%lld\n",max); }}
- Okabe and Banana Trees 思路题
- CF821B-Okabe and Banana Trees
- Codeforces821B 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
- #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(数学)
- C++中检查浮点数值有效性
- 蓝桥杯练习题之回文数
- 一些Unity 小提示
- Liunx Zookeeper集群安装
- 最基础的HTML知识点
- Okabe and Banana Trees 思路题
- MySQL使用存储实现快速创建多分表
- Collections.sort()方法的使用及Comparable和comparator的qubie
- 开发环境搭建-Spring Tool Suite安装
- 正交向量和子空间学习
- ROS包全攻略:消息vs服务;可执行vs插件
- 自己来写RPC框架—第一章
- 四、Android安全机制之数据加密
- 最全的常用正则表达式大全