3.cpp 384 B

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