D1

T1 转圈游戏

 

快速幂

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 using namespace std;
 5 int n,m,k,x,ans=1;
 6 long long power(long long x,long long y)
 7 {
 8     if(y==0)return 1;
 9     if(y==1)return x%n;
10     long long m=y/2,ans;
11     bool r=y%2;
12     ans=power(x,y/2);
13     if(r)return ((ans*ans)%n*x)%n;
14     else return (ans*ans)%n;
15 }
16 int main()
17 {
18     freopen("circle.in","r",stdin);
19     freopen("circle.out","w",stdout);
20     cin>>n>>m>>k>>x;
21     ans=(power(10%n,k)*m+x%n)%n;
22     cout<<ans;
23     fclose(stdin);fclose(stdout);
24     return 0;
25 }
View Code

相关文章:

  • 2021-10-02
  • 2020-03-19
  • 2018-05-13
  • 2018-06-13
  • 2018-07-02
  • 2019-12-16
  • 2019-02-28
  • 2019-11-07
猜你喜欢
  • 2021-08-04
  • 2020-12-29
  • 2021-08-04
  • 2017-12-16
  • 2020-03-22
  • 2021-10-10
  • 2021-08-04
  • 2021-11-16
相关资源
相似解决方案