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

哪里错了,为何wa

Posted by wangmj17 at 2012-04-23 21:15:39 on Problem 1061
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
long long x,y,e;
void gcd(long long a,long long b,long long c)
{
     if(a==0)
     {x=0,y=c/b,e=b;return;}
     gcd(b%a,a,c);
     long long t=y;
     y=x,x=t-(b/a)*x;    
}
int main()
{
    long long a,b,m,n,l;
    scanf("%I64d%I64d%I64d%I64d%I64d",&a,&b,&m,&n,&l);
    if(m<n)swap(a,b),swap(m,n);
    gcd(m-n,l,b-a);
    if((b-a)%e!=0)printf("Impossible\n");
    else
    {
        if(e!=0)
        {
        long long d=(m-n)*l/e;
        if(x<1){x+=(-x+1)/(d/(m-n))*d/(m-n);if(x<1)x+=d/(m-n);}
        else x-=(x-1)/(d/(m-n))*(d/(m-n));
        }
        printf("%I64d\n",x);
    }
    
    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