| ||||||||||
| 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 | |||||||||
这还不暴力。。。。In Reply To:Re:请教非暴力,非打表的做法 Posted by:Hacker_QC at 2005-08-25 01:19:37 > #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