下面这个程序可以对付非互素的同余
#include 
#include 
#include 
#include 
using namespace std;

__int64 x, y, t;

__int64 egcd(__int64 a, __int64 b) 
{
    if (b==0)   
    {
        x=1;      
        y=0;   
        return a;   
    }
    else 
    {
        __int64 e=egcd(b,a % b); 
        t=x; 
        x=y;
        y=t-a/b*y;   
        return e;   
    }
}

__int64 gcd(__int64 x, __int64 y)
{
    if (!x || !y)
        return x > y ? x : y;
    for (__int64 t; t = x % y; x = y, y = t);
    return y;
}
__int64 mm[10],rr[10];

int main() 
{
    //freopen("in.txt", "r", stdin); 
    __int64 m1,m2,r1,r2,d,c,t;
    bool flag;   
    __int64 n;   
    __int64 tc,cnt=0;
    scanf ("%I64d",&tc);

    while (tc--)    
    {
        cnt++;
        scanf ("%I64d",&n);
        flag=0;          
        for (__int64 i=0;i1)
            {
                r1=mm[0];
                __int64 ans=1;
                for (int i=1;i;i++)>;i++)>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-07-27
  • 2022-12-23
  • 2021-12-18
  • 2021-10-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-09-04
  • 2021-10-10
  • 2021-07-30
  • 2022-12-23
相关资源
相似解决方案