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 eulerray at 2007-08-11 11:08:48 on Problem 2590
In Reply To:Re:WA的进来看看! Posted by:apple0227 at 2007-08-06 15:26:38
#include<iostream.h>
#include<stdio.h>
同时用这两个会产生错误吧

我把你的代码的输入输出统一后就AC了

#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;
    scanf("%d",&N);
    while(N--)
    {
        scanf("%I64d%I64d",&x,&y);
        m=fab(x-y);
      if(m==0) {
               printf("0\n");
               continue;
               }
     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