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:the rule

Posted by SongLijun at 2009-02-26 21:29:50 on Problem 2590
In Reply To:Re:the rule Posted by:zhouqian at 2008-11-19 22:26:37
//和大牛思想一样
unsigned  a[100000];
int main()
{
    int i,j,k=1,m,n,t=1;
    a[1]=1;a[2]=2;
    for(i=3;;i++)
    {
        a[i]=a[i-1]+(i+1)/2;
        if(a[i]>two(31)) break;
    }    
    k=i;
    scanf("%d",&t);
    while(t--)
    {
		scanf("%d%d",&n,&m);
		n=m-n;
		if(n==0)
		{
		    printf("0\n");
		    continue;
		}    
		else if(n==1)
		{
		    printf("1\n");
		    continue;
		}    
		int ll=1,rr=k,mid;
		while(ll<rr)
		{
		    mid=(ll+rr)>>1;
		    if(n<=a[mid]) rr=mid;
		    else ll=mid+1;
		}    
        printf("%d\n",ll);
    }
    system("pause");
    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