#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
#define ENTER printf("\n");
//快速打印一个数组
#define ll long long
#define NUM 100
#define MOD 1000
using namespace std;
//构造函数 析构函数怎么打印出地址
int cubic[53 + 1];
int tet[95 + 1];
int n;
//在cubic中二分查找最大的那个小于x的数
int binary_search(int cubic[], int x)
{
int left = 1;
int right = 53;
int mid;
while (left + 1 < right)
{
mid = (left + right) >> 1;
if (cubic[mid] == x)
{
return x;
}
else if (cubic[mid] < x)
{
left = mid;
}
else
{
right = mid;
}
}
return cubic[left];
}
int binary_search1(int tet[], int x)
{
int left = 1;
int right = 95;
int mid;
while (left + 1 < right)
{
mid = (left + right) >> 1;
if (tet[mid] == x)
{
return x;
}
else if (tet[mid] < x)
{
left = mid;
}
else
{
right = mid;
}
}
return tet[left];
}
int main()
{
for (int i = 1; i <= 53; i++)
{
cubic[i] = i * i * i;
}
for (int i = 1; i <= 95; i++)
{
tet[i] = i * (i + 1) * (i + 2) / 6;
}
while (scanf("%d", &n) != EOF && n)
{
int a1 = binary_search1(cubic, n);
int a2 = binary_search1(tet, n);
int a3 = 0x80000000;
for (int i = 1; i <= 53; i++)
{
for (int j = 1; j <= 95; j++)
{
if (cubic[i] + tet[j] > n)
break;
a3 = max(cubic[i] + tet[j], a3);
}
}
printf("%d\n", max(a1, max(a2, a3)));
}
return 0;
}
03-24
850
07-26
1090
08-29
516
08-05
351