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 xiao1590 at 2007-03-17 17:34:22 on Problem 2309
#include <stdio.h>

__int64 lst[33]={2};

__int64 findn(__int64 root)
{
	int i;
	for (i=0;i<33;i++)
	{
		if (lst[i]>root)
		{
			if (lst[i]-root<root-lst[i-1])
				return lst[i]-root;
			else
			{
				if (root-lst[i-1]!=0)
					return root-lst[i-1];
				else
					return lst[i]-root;
			}
		}
	}
}

void findlr(__int64 root,__int64 n,__int64 &l,__int64 &r)
{
	while (n/=2)
	{
		l-=n;
		r+=n;
	}
}

void main()
{
	__int64 N,i,root,n,l,r;
	for (i=1;i<33;i++)
		lst[i]=lst[i-1]*2;
	scanf("%I64d",&N);
	while (N--)
	{
		scanf("%I64d",&root);
		l=r=root;
		if (root%2==0)
		{
			n=findn(root);
			findlr(root,n,l,r);
		}
		printf("%I64d %I64d\n",l,r);
	}
}

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