Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:WA的进来看看!

Posted by apple0227 at 2007-08-06 15:26:38 on Problem 2590
In Reply To:WA的进来看看! Posted by:eulerray at 2007-07-14 21:42:57
> 注意两个点相同的情况!这时要输出0
> 第一次代码AC了,把判断0的语句删除就WA
我输出了但是还是WA
#include<iostream.h>
 
#include<stdio.h>
#include<math.h>
__int64 fab(__int64 a)
{
     if(a>=0) return a;
     else  return -a;   
}
int main()
{
    __int64 x,y,n,sum,m,rest;
    int N;
    cin>>N;
    while(N--)
    {
        scanf("%I64d%I64d",&x,&y);
        m=fab(x-y);
if(m==0) cout<<"0"<<endl;
else{
        sum=0; n=1;
        while((sum+n+n-1)<m)
        {
            sum+=(n+n-1);
            n++;
        }
        rest=m-sum;
        if(rest<n&&rest>0)
            printf("%I64d\n",2*n-2);
        else
            printf("%I64d\n",2*n-1);}
    }     
 
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator