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

相关文章:

  • 2022-01-27
  • 2021-08-23
  • 2021-07-07
  • 2022-01-22
  • 2021-06-12
  • 2022-12-23
  • 2022-01-22
  • 2021-10-29
猜你喜欢
  • 2021-08-03
  • 2022-02-27
  • 2021-10-31
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案