模拟真的能行?(无快速幂)
查看原帖
模拟真的能行?(无快速幂)
696996
restart_to_revive楼主2024/10/2 19:30
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,m,k,x;
    cin>>n>>m>>k>>x;
    long long posm=m;
    long long x1=x;
    for(int i=0;i<k/11;i++){
        long long c=x1+1000000000*posm*100;
        x1=c-c/n*n;
        /*for(int j=0;j<10;j++){
            x1=(x1+m)%n;
        }*/
        posm=x1-x;
		x1=x;
    }
    for(int i=0;i<k%11;i++){
        long long c=x1+10*posm;
        x1=c-c/n*n;
        /*for(int j=0;j<10;j++){
            x1=(x1+m)%n;
        }*/
        posm=x1-x;
		x1=x;
    }
    long long d=x+posm;
	if(d<0) d+=n;
    cout<<d%n;
    return 0;
}

求 Hack

2024/10/2 19:30
加载中...