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

水过0ms

Posted by water123 at 2010-11-20 10:36:45 on Problem 1730
#include<stdio.h>
#include<math.h>

int main(){
	__int64 x,z;
	int i,y,p;
	while(1){
		scanf("%I64d",&x);
		if(x==0)break;
		if(x==1||x==-1)continue;
		p=1;
		if(x>0){
			for(i=2;;i++){
				y=(int)pow(x*1.0,1.0/i);
				if(y<2)break;
				z=(__int64)pow(y+0.0,i);
				if(x==z)p=i;
				else{
					z=(__int64)pow(y+1.0,i);
					if(x==z)p=i;
				}
			}
		}else{
			x=-x;
			for(i=3;;i+=2){
				y=(int)pow(x*1.0,1.0/i);
				if(y<2)break;
				z=(__int64)pow(y+0.0,i);
				if(x==z)p=i;
				else{
					z=(__int64)pow(y+1.0,i);
					if(x==z)p=i;
				}
			}
		}
		printf("%d\n",p);
	}
	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