# uva 374 - Big Mod link: https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=310 ```cpp= #include<iostream> using namespace std; typedef long long ll; ll mod(int x, int y, int k){ if (y == 0) return 1; if (y % 2) return (mod(x, y-1, k) * x) % k; ll tmp = mod(x, y/2, k); return (tmp*tmp) % k; } int main(){ ios::sync_with_stdio(0); cin.tie(0); ll b, p, m; while(cin >> b >> p >> m){ cout<< mod(b, p, m) <<endl; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up