Advertisement
a53

Putere1

a53
Jan 27th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int b,MOD=1;
  4. int compute(int p)
  5. {
  6. if(p==0)
  7. return 1;
  8. int x=compute(p/2);
  9. x=( 1ULL*x*x)%MOD;
  10. if(p%2)
  11. x=(1ULL*x*b)%MOD;
  12. return x;
  13. }
  14.  
  15. int main()
  16. {
  17. int n,p;
  18. cin>>b>>n>>p;
  19. for(int i=1;i<=p;++i)
  20. MOD*=10;
  21. cout<<compute(n);
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement