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:单纯找规律水题,贴一个自己的代码吧。。。In Reply To:单纯找规律水题,贴一个自己的代码吧。。。 Posted by:neofung at 2011-09-07 16:59:35 > #include <stdio.h> > > int main(void) > { > int ncases; > int a,b,len; > scanf("%d",&ncases); > > while(ncases--) > { > scanf("%d %d",&a,&b); > len=b-a; > > int temp=0; > int index; > for(int i=0;;++i) > { > if(len<=temp+(i+1)/2) > { > index=i; > break; > } > temp+=(i+1)/2; > } > printf("%d\n",index); > } > > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator