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

Re:下面是小弟写的。

Posted by MasterLuo at 2008-07-08 18:12:05 on Problem 2309
In Reply To:菜鸟拙见:给定N,如果S=N, S%2!=0表示到达最底层(奇数),而在上面第K层有(S-MIN)=(MAX-S)=2^(K-1).故可求。 Posted by:MasterLuo at 2008-07-08 18:11:09
while(n--)
	{
		scanf("%I64d", &s);
		min=max=temp=s, t=0;
		while(temp%2==0)
		{
			t++;
			temp/=2;
		}
		for(int i=t-1; i>=0; i--)
		{
			min-=a[i];
			max+=a[i];
		}
		printf("%I64d %I64d\n", min, max);
	}

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