luogu P1965 转圈游戏 题目

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<ctime>
#include<queue>
#include<stack>
#define rg register
#define lst long long
#define N
using namespace std;

lst n,m,k,x,ans;
//(10^k%n*m%n+x)%n
inline lst read()
{
    rg lst s=0,m=1;rg char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
    if(ch=='-')m=-1,ch=getchar();
    while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
    return s*m;
}

inline lst qpow(rg lst a,rg lst b)
{
    rg lst base=a,res=1;
    while(b)
    {
        if(b&1)res=(res*base)%n;
        base=(base*base)%n;
        b>>=1;
    }
    return res;
}

int main()
{
    n=read(),m=read(),k=read(),x=read();
    ans=qpow(10,k);
    ans=(ans*m)%n;
    ans=(ans+x)%n;
    printf("%lld\n",ans);
    return 0;
}

 

相关文章:

  • 2021-08-01
  • 2021-08-19
  • 2021-07-04
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2021-12-26
  • 2021-08-27
猜你喜欢
  • 2021-05-18
  • 2022-01-24
  • 2021-07-07
  • 2021-11-27
  • 2021-10-17
  • 2022-01-10
  • 2021-11-08
相关资源
相似解决方案