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 |
暴力一下#include <iostream> #include <stdio.h> using namespace std; int aMx = 1, bMx = 1; bool ky[151201] = {0}; int A[1024] = {0}, B[1024] = {0}; void preprocess(){ for(; ; aMx++){ int c = aMx*aMx*aMx; if(c > 151200) break; A[aMx] = c; } for(; ; bMx++){ int c = bMx*(bMx-1)*(bMx-2)/6; if(c > 151200) break; B[bMx] = c; } for(int i = 0; i < aMx; i++){ for(int j = 0; j < bMx; j++){ int k = A[i] + B[j]; if(k > 151200) break; ky[k] = 1; } } } int main() { preprocess(); while(1){ int n; scanf("%d", &n); if(!n) break; for(; ; n--){ if(ky[n]){ printf("%d\n", n); break; } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator