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

Re:各位牛人,有谁有更好的方法你们的怎么是0MS呢? 我的是这样的,希望找到更好的方法!谢谢!

Posted by H_Roc at 2009-01-10 15:16:15 on Problem 1543
In Reply To:各位牛人,有谁有更好的方法你们的怎么是0MS呢? 我的是这样的,希望找到更好的方法!谢谢! Posted by:wuqianhu12 at 2006-12-07 21:15:10
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int N = 3;
	while(N <=n){
		for(int i=2;;i++){
			if(i*i*i > N*N*N)	break;
			for(int j=i+1;;j++){
				if(i*i*i+j*j*j > N*N*N)	break;
				for(int k=j+1;;k++){
					int tmp = i*i*i + j*j*j + k*k*k;
					if(tmp == N*N*N)
						printf("Cube = %d, Triple = (%d,%d,%d)\n",N,i,j,k);
					else if(tmp > N*N*N)
							break;
				}
			}
		}
		N++;
	}system("pause");
	return 0;
}

0s AC....

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