| ||||||||||
| 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:在ZOJ上能过,为什么在POJ上便WA????HELP!!!!In Reply To:在ZOJ上能过,为什么在POJ上便WA????HELP!!!! Posted by:Tju_Rocket at 2005-08-17 21:00:17 > [code]:
> #include<iostream>
> #include<cmath>
> using namespace std;
> int main()
> {
> int a,b,step,num,n,n1,step1,step2,num1,num2, V;
**
** cin>>testcase; //add this line
**
> while(cin>>a>>b)
> {
> step=0;
> if(a==b||a==b+1||a==b+2)
> cout<<b-a<<endl;
> else
> {
> num=b-a;
> n1=int(sqrt(double(num)));
> num1=int(sqrt(double(1+4*num)));
> n=(-1+num1)/2;
> num1=num-n1*n1;
> num2=num-(n+1)*n;
> if(n1>=num1)
> {
> step1=(n1-1)*2+1;
> if(num1)step1++;
> step=step1;
> }
> else if(n>=num2)
> {
> step2=n*2;
> if(num2)step2++;
> step=step2;
> }
>
> cout<<step<<endl;
> }
> }
> return 0;
> }
>
>
>
>
>
>
>
>
>
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator