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:水题是勿用质疑的,但是我还是用了360ms,有跟简单的方法吗?

Posted by yogafrank at 2008-11-08 10:51:14 on Problem 1543
In Reply To:水题是勿用质疑的,但是我还是用了360ms,有跟简单的方法吗? Posted by:wuzhipingdixiao at 2008-11-07 22:37:47
这个32MS可以AC的。好像就是暴力吧。

#include <iostream>
using namespace std;

void check( int v )
{
	int i, j, k, t = v;
	v = v * v * v;
	for( i = 2; i * i * i <= v; i++ )
		for( j = i; j * j * j + i * i * i <= v; j++ )
			for( k = j; k * k * k + j * j * j + i * i * i <= v; k++ )
				if( k * k * k + j * j * j + i * i * i == v )
					cout << "Cube = " << t << ", Triple = " << "(" << i << "," << j << "," << k << ")" << endl;
}

int main()
{
	int n;

	cin >> n;
	for( int i = 1; i <= n; i++ )
		check( i );

	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