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

pow很牛啊

Posted by nothing828 at 2010-09-09 11:30:23 on Problem 1289
#include<iostream>
#include<math.h>
using namespace std;

#define UI unsigned __int64

int main()
{
	UI hei,num,k,M,N=1;
	while(scanf("%I64u%I64u",&hei,&num) && (hei+num))
	{
		if(num==1)
		{
			k=0;
			while(hei!=1)
			{
				hei/=2;
				k++;
			}
			printf("%I64u %I64u\n",k,(UI)pow(2,(double)(k+1))-1);
			continue;
		}
		for(k=1;;k++)
		{
			M=pow(hei,1.0/k)+0.9999999;
			N=pow(num,1.0/k)+0.9999999;
			if(M==N+1 && hei==(UI)pow(M,(double)k) && num==(UI)pow(N,(double)k))
				break;
		}
		printf("%I64u %I64u\n",(num-1)/(N-1),hei*(N+1)-num*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