首页 > 代码库 > CF821B Okabe and Banana Trees

CF821B Okabe and Banana Trees

思路:

暴力枚举。

实现:

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 typedef long long ll;
 5 ll m, b;
 6 int main()
 7 {
 8     cin >> m >> b;
 9     ll maxn = 0;
10     for (ll i = 0; i <= m * b; i++)
11     {
12         ll j = - i / m + b;
13         if (m * j + i - m * b <= 0)
14         {
15             ll ans = (i + 1) * (j + 1) * (i + j) / 2;
16             if (ans > maxn) 
17                 maxn = ans;
18         }
19     }
20     cout << maxn << endl;
21     return 0;
22 }

 

CF821B Okabe and Banana Trees