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:水题是勿用质疑的,但是我还是用了360ms,有跟简单的方法吗?In Reply To:水题是勿用质疑的,但是我还是用了360ms,有跟简单的方法吗? Posted by:wuzhipingdixiao at 2008-11-07 22:37:47 这个32MS可以AC的。好像就是暴力吧。 #include <iostream> using namespace std; void check( int v ) { int i, j, k, t = v; v = v * v * v; for( i = 2; i * i * i <= v; i++ ) for( j = i; j * j * j + i * i * i <= v; j++ ) for( k = j; k * k * k + j * j * j + i * i * i <= v; k++ ) if( k * k * k + j * j * j + i * i * i == v ) cout << "Cube = " << t << ", Triple = " << "(" << i << "," << j << "," << k << ")" << endl; } int main() { int n; cin >> n; for( int i = 1; i <= n; i++ ) check( i ); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator