求助0pts求调qwq
查看原帖
求助0pts求调qwq
1054119
xzq4121楼主2024/8/12 11:36
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll m,a,c,x,n,g,ju[3][3],ans[3][3],chu[3][2];
void chen1(){
	long long b[105][105]={0};
	for(int i=1;i<=2;i++) for(int j=1;j<=2;j++) for(int k=1;k<=2;k++) b[i][j]=__int128(b[i][j]+ans[i][k]*ju[k][j])%m;
	for(int i=1;i<=2;i++) for(int j=1;j<=2;j++) ans[i][j]=b[i][j];
}
void chen2(){
	long long b[105][105]={0};
	for(int i=1;i<=2;i++) for(int j=1;j<=2;j++) for(int k=1;k<=2;k++) b[i][j]=__int128(b[i][j]+ju[i][k]*ju[k][j])%m;
	for(int i=1;i<=2;i++) for(int j=1;j<=2;j++) ju[i][j]=b[i][j];
}
void mi(ll y){
    while(y){
        if(y&1) chen1();
        chen2();
        y>>=1;
    }
}
int main(){
    scanf("%lld %lld %lld %lld %lld %lld",&m,&a,&c,&x,&n,&g);
    ans[1][1]=ans[2][2]=1;
    ju[1][1]=a;
    ju[1][2]=1;
    ju[2][1]=0;
    ju[2][2]=1;
    chu[1][1]=x;
    chu[2][1]=c;
    mi(n);
    printf("%lld\n",(long long)(__int128(ans[1][1]*chu[1][1]+ans[1][2]*chu[2][1]+ans[1][1]*chu[2][1]+ans[1][2]*chu[1][1])%g));
    return 0;
}
2024/8/12 11:36
加载中...