Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

暴力一下

Posted by KatrineYang at 2016-11-01 01:46:32 on Problem 1406
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator