蒟蒻求教,望各位大佬能相助!
查看原帖
蒟蒻求教,望各位大佬能相助!
316062
K___楼主2020/9/19 09:53

请问大佬们,下面这份代码是哪里有问题吗?

WA了八个点啊啊啊

#include <iostream>
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
LL x,y;
LL s1,s2,m,n,l;
LL exgcd(LL a,LL b)
{
    if(b==0) {x=1,y=0;return a;}
    LL t=exgcd(b,a%b);
    LL temp=x; x=y;
    y=temp-a/b*y;
    return t;
}
int main()
{
    cin>>s1>>s2>>m>>n>>l;
    LL a=n-m,b=s1-s2;
    if(a<0) b=-b,a=-a;
    LL ans=exgcd(a,l);
    if(b%ans!=0) cout<<"Impossible"<<endl;
    else cout<<((x*(b/ans))%(l/ans)+(l/ans))%(l/ans);
    return 0;
}

2020/9/19 09:53
加载中...