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

为什么用__int64就AC,long就RE

Posted by nepepl at 2010-05-05 23:22:20 on Problem 1061
下面是AC代码,如果long是WA还可以接受,但实在无法理解为什么long会RE,
#include<iostream>
using namespace std;
__int64 extended_euclid(__int64 a,__int64 b,__int64 &x,__int64 &y)
{
    __int64 ret;
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    ret=extended_euclid(b,a%b,x,y);
    __int64 t=x;
    x=y;
    y=t-a/b*y;
    return ret;
}
int main()
{
	__int64 x,y,m,n,L;
	__int64 d,a,b,temp;
	scanf("%I64d %I64d %I64d %I64d %I64d",&x,&y,&m,&n,&L);
	d=extended_euclid(n-m,L,a,b);
	if((x-y)%d)
		printf("Impossible\n");
	else
	{
		L=L/d;
		temp=(x-y)/d*a;
		temp=temp%L;
		while(temp<0)
			temp=temp+L;
		printf("%I64d\n",temp);
	}
	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