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:请教非暴力,非打表的做法

Posted by Hacker_QC at 2005-08-25 01:19:37 on Problem 1543
In Reply To:请教非暴力,非打表的做法 Posted by:sunmoonstar_love at 2005-08-24 20:12:36
#include <stdio.h>
#include <math.h>
int main() {
	int n,a,b,c,d,t;
	while( scanf("%d",&n)!=EOF ) {
		for( a=6; a<=n; ++a )
			for( b=2; b<=a; ++b )
				for( c=b; c<=a; ++c ) {
					if( b*b*b+c*c*c>=a*a*a ) continue;
					t=a*a*a-b*b*b-c*c*c;
					d=int(pow(t,1.0/3.0)+1e-5);
					if( d*d*d==t && d>=c ) printf("Cube = %d, Triple = (%d,%d,%d)\n",a,b,c,d);
				}
	}
	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