洛谷 1965 转圈游戏——水题

题目:https://www.luogu.org/problemnew/show/P1965

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,k,x,d;
int pw(int x,int k)
{
  int ret=1;while(k){if(k&1ll)ret=(ll)ret*x%n;x=(ll)x*x%n;k>>=1ll;}return ret;
}
int main()
{
  scanf("%d%d%d%d",&n,&m,&k,&x);
  d=pw(10,k);
  d=(ll)d*m%n;
  x=(x+d)%n;
  printf("%d\n",x);
  return 0;
}

 

posted on 2018-09-14 17:33  Narh  阅读(117)  评论(0编辑  收藏  举报

导航