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 |
Re:请教非暴力,非打表的做法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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator