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

狂晕,用C++交WA,用G++交AC,到底是怎么回事啊??

Posted by apple0227 at 2007-08-06 15:22:50 on Problem 2590
#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