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 |
各位牛人,有谁有更好的方法你们的怎么是0MS呢? 我的是这样的,希望找到更好的方法!谢谢!#include <stdio.h> #include <stdlib.h> int main () { int M,N,i,j,k,x,m,n,t,Cube,Ttiple; scanf("%d",&N); if(N>1&&N<=100) { for(x=2;x<=N;x++) { M=x*x*x; for(i=2;i<=N;i++) { m=i*i*i; for(j=2;j<=N;j++) { n=j*j*j; for(k=2;k<=N;k++) { t=k*k*k; if(m+n+t==M) if(i<=j&&j<=k) printf("Cube = %d, Triple = (%d,%d,%d)\n", x,i,j,k); } } } } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator