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,不能用double,wa到疯#include<iostream> #include<cmath> using namespace std; int main() { int numb, numn; cin >> numb >> numn; while(numb != 0 && numn != 0) { int cha1, cha2; int res = 1, temp1 = pow(double(res), numn), temp2; while(true) { cha1 = numb - temp1; cha1 = cha1 < 0 ? (-cha1) : cha1; temp2 = pow(double(res + 1), numn); cha2 = numb - temp2; cha2 = cha2 < 0 ? (-cha2) : cha2; if(cha1 > cha2) { temp1 = temp2; } else { break; } res++; } cout << res << endl; cin >> numb >> numn; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator