Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define pb push_back
  3. #define L long long
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(0);
  8. //freopen("input.txt", "r", stdin);
  9. //freopen("output.txt", "w", stdout);
  10. long double m,b;
  11. cin >> m >> b;
  12. long double x = 0, y = b;
  13. long long ans = 0;
  14. while (y >= 0) {
  15. L cur = 0, add = 0, yy = (int) y;
  16. if (x!=0 && y!=0) {
  17. cur=(yy + 1) * ((x + 1) * x / 2) + (x + 1) * ((yy + 1) * yy / 2);
  18. ans = max(ans, cur);
  19. }
  20. if (x==0 && y==0) {
  21.  
  22. x++;
  23. y = -(x/m) + b;
  24. continue;
  25. }
  26. if (x == 0) {
  27. L d=(x + 1) * ((yy + 1) * yy / 2);
  28. ans = max(ans, d);
  29. } else if (yy == 0) {
  30. L d=(yy + 1) * ((x + 1) * x / 2);
  31. ans = max(ans, d);
  32. }
  33.  
  34.  
  35. x++;
  36. y = -(x/m) + b;
  37. }
  38. cout << ans << endl;
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement