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 |
为什么暴力求解WA了,感觉思路没错。。跪求大神指教#include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #include<cmath> using namespace std; int main() { int t,a,b; long long x,sum; scanf("%d",&t); while(t--) { scanf("%d%d",&a,&b); if(abs(a-b)<=3) printf("%d\n",abs(a-b)); else { a+=1; sum=x=2; while(a!=b-1) { if(a+x<=b-1) { sum++; a+=x; x++; } else x--; } printf("%I64d\n",sum); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator