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 |
用pow()很耗时间吗?//同样的代码,我如果用pow就超时,不用就ac,纳闷了??? #include <iostream> #include <math.h> using namespace std; int main() { int max; cin>>max; int now=6; while(now<=max) { for(int i=2;i<now;i++) { for(int j=i;j<now;j++) { for(int k=j;k<now;k++) { if(now*now*now==(i*i*i+j*j*j+k*k*k)) // if(pow(now,3)==(pow(i,3)+pow(j,3)+pow(k,3))) cout<<"Cube = "<<now<<", Triple = ("<<i<<","<<j<<","<<k<<")"<<endl; } } } now++; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator