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:各位牛人,有谁有更好的方法你们的怎么是0MS呢? 我的是这样的,希望找到更好的方法!谢谢!In Reply To:各位牛人,有谁有更好的方法你们的怎么是0MS呢? 我的是这样的,希望找到更好的方法!谢谢! Posted by:wuqianhu12 at 2006-12-07 21:15:10 #include<iostream> #include<stdio.h> using namespace std; int main() { int n; cin >> n; int N = 3; while(N <=n){ for(int i=2;;i++){ if(i*i*i > N*N*N) break; for(int j=i+1;;j++){ if(i*i*i+j*j*j > N*N*N) break; for(int k=j+1;;k++){ int tmp = i*i*i + j*j*j + k*k*k; if(tmp == N*N*N) printf("Cube = %d, Triple = (%d,%d,%d)\n",N,i,j,k); else if(tmp > N*N*N) break; } } } N++; }system("pause"); return 0; } 0s AC.... Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator