比大小

传送门

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define re register
void read(int &a)
{
    a=0;
    int d=1;
    char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
struct note
{
    int a[5][5];
}tem,ans;
inline void init(ll a)
{
    tem.a[1][1]=a;
    tem.a[1][2]=0;
    tem.a[2][1]=1;
    tem.a[2][2]=1;
}
note Mat(note x,note y)
{
    note c;
    for(re int i=1;i<=2;i++)
        for(re int j=1;j<=2;j++)
            c.a[i][j]=0;
    for(re int i=1;i<=2;i++)
        for(re int j=1;j<=2;j++)
            for(re int k=1;k<=2;k++)
                c.a[i][j]=(c.a[i][j]+x.a[i][k]*y.a[k][j]%4)%4;
    return c;
}
char s[4]={'<','=','<','>'};
int main()
{
    int T;
    read(T);
    while(T--)
    {
        ll A0,a,b,N;
        scanf("%lld %lld %lld %lld",&A0,&a,&b,&N);
        if((!A0&&!N)||(!a&&!b))
        {
            puts("=");
            continue;
        }
        A0%=4,a%=4,b%=4;
        init(a);
        for(re int i=1;i<=2;i++)
            for(re int j=1;j<=2;j++)
                ans.a[i][j]=0;
        for(re int i=1;i<=2;i++)
            ans.a[i][i]=1;
        while(N)
        {
            if(N&1)
                ans=Mat(ans,tem);
            tem=Mat(tem,tem);
            N>>=1;
        }
        A0=(A0*ans.a[1][1]+b*ans.a[2][1])%4;
        putchar(s[A0]);
        putchar('\n');
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/acm1ruoji/p/10874929.html