| ||||||||||
| 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 | |||||||||
这道题贪心就行了In Reply To:请教牛人们觉得没错,为什么会WA呢???????????????????? Posted by:jiabiao at 2005-08-17 23:22:36 > #include<stdio.h>
> void main()
> {
> long x,y,i,n,m,sum,data,count;
> scanf("%ld",&n);
> for(i=0;i<n;i++)
> {
> scanf("%ld %ld",&x,&y);
> x++;y--;
> m=y-x;
> data=2;sum=x;count=2;
> while(sum<y)
> {
> if(sum+data>=y)
> {
> printf("%ld\n",++count);
> break;
> }
> if(sum+data<y)
> {
> sum=sum+data;
> data++;count++;
> }
> }
> }
> }
>
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator