Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:the ruleIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator