水题,直接贴代码。
//poj 1406
//sep9
# include<iostream>
using namespace std;
__int64 f1[2024];
__int64 f2[3024];
int main()
{__int64 index1=0,index2=0,n;for(index1=0;index1<1300;++index1)f1[index1]=index1*index1*index1;for(index2=0;index2<2350;++index2)f2[index2]=index2*(index2+1)*(index2+2)/6; while(scanf("%I64d",&n)&&n){__int64 maxx=0; __int64 i,j;for(i=0;i<index1&&f1[i]<=n;++i)for(j=0;j<index2;++j)if(f1[i]+f2[j]<=n)maxx=max(maxx,f1[i]+f2[j]);else break;printf("%I64d\n",maxx);}return 0;
}