3.cpp 402 B

12345678910111213141516
  1. //我是个傻逼
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int encrypt(int m,int e,int n){int c=1;for(int i=0;i<e;i++){c=(c*m)%n;}return c;}
  5. int decode(int c,int d,int n){int m=1;for(int i=0;i<d;i++){m=(m*c)%n;}return m;}
  6. int m,c,e,n,d;
  7. int main (){
  8. cin>>n>>e>>d;
  9. cin>>m;
  10. c=encrypt(m,e,n);
  11. cout<<c<<endl;
  12. m=decode(c,d,n);
  13. cout<<m<<endl;
  14. system("pause");
  15. return 0;
  16. }