Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int b,MOD=1;
- int compute(int p)
- {
- if(p==0)
- return 1;
- int x=compute(p/2);
- x=( 1ULL*x*x)%MOD;
- if(p%2)
- x=(1ULL*x*b)%MOD;
- return x;
- }
- int main()
- {
- int n,p;
- cin>>b>>n>>p;
- for(int i=1;i<=p;++i)
- MOD*=10;
- cout<<compute(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement