JZOJ 3532. 【NOIP2013提高组day1】转圈游戏
题目
分析
显然答案为(x+m*10^k)%n 快速幂
代码
1 #include <iostream> 2 #include <cmath> 3 #include <algorithm> 4 #include <cstdio> 5 #define maxp 1505 6 #define maxf 205 7 8 using namespace std; 9 10 long long n,m,s,t,ans,k,x; 11 int map[maxp][maxp],dis[maxp][maxp]; 12 int into[maxf],outo[maxf],a[maxf],b[maxf]; 13 14 long long ksm(long long a,long long b) 15 { 16 long long x=a,ans=1; 17 while (b) 18 { 19 if (b&1!=0) ans*=x; 20 ans%=n; 21 x*=x; 22 x%=n; 23 b>>=1; 24 } 25 return ans%n; 26 } 27 int main() 28 { 29 scanf("%d%d%d%d",&n,&m,&k,&x); 30 // for (int i=1;i<=n;i++) 31 // { 32 // scanf("%d%d",&a[i],&b[i]); 33 // } 34 cout<<(m*ksm(10,k)+x)%n; 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 }
为何要逼自己长大,去闯不该闯的荒唐