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:WA的进来看看!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator