首页 > 其他 > 详细

比大小

时间:2019-05-16 13:05:48      阅读:118      评论:0      收藏:0      [点我收藏+]

传送门

#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;
}

 

比大小

原文:https://www.cnblogs.com/acm1ruoji/p/10874929.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!