Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮我看看,测试数据都对,就是不能通过

Posted by hqhhq at 2007-12-26 00:43:57 on Problem 3100
#include <cstdio>

using namespace std;

int pow(int base, int n){
int result = 1;
for(int i = 0; i < n; ++i){
result *= base;
}
return result;
}

int main(){
int B, N;
int p1, p2;
scanf("%d %d", &B, &N);
while(true){
if((B == 0) && (N == 0)) {
break;
}else {
if(B == 1){
printf("1\n");
}else{
for(int i = 0; i < 1001; ++i){
p1 = pow(i, N);
p2 = pow(i + 1, N);
if(p1 <= B && p2 >=B){
if(B - p1 > p2 - B){
printf("%d\n", i + 1);
}else{
printf("%d\n", i);
}
break; // already get the answer, quit
}
}
}
}
scanf("%d %d", &B, &N);
}

return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator