Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
及其暴力的办法,AC#include <iostream.h> int main() { int num; // int max; int min; while(1) { cin>>num; if(num==0)break; min=num; for(int i=0;;i++) { int temp=i*i*i; if(temp==num) { min=0; break; } if(temp>num)break; if(min>(num-temp)) { min=num-temp; if(min==0)break; } int te; int flag=0; for(int k=1;;k++) { te=k*(k+1)*(k+2)/6+temp; if(te==num) { min=0; flag=1; break; } if(te>num) { break; } if(min>(num-te)) { min=num-te; if(min==0) { flag=1; break; } } } if(flag==1)break; }//for cout<<num-min<<endl; } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator