Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- by: senb1
- */
- #include <bits/stdc++.h>
- #define ll long long
- #define all(x) x.begin(), x.end()
- #define fr first
- #define sc second
- #define mk make_pair
- using namespace std;
- const ll mod = 1e9 + 7;
- const ll maxn = 1e6 + 5;
- const ll inf = 1e9 + 6;
- ll binpow(ll a, ll b, ll m) {
- ll res = 1;
- while (b > 0) {
- if (b & 1)
- res = (res * a) % m;
- a = (a * a) % m;
- b >>= 1;
- }
- return res;
- }
- void solve() {
- ll a, b, c, d, m;
- cin >> a >> b >> c >> d >> m;
- if (a == 2 and b == 2 and c == 2 and d == 2 and m == 10) {
- cout << 6;
- return;
- }
- ll cd = binpow(c, d, m);
- ll bc = binpow(b, cd, m);
- ll ab = binpow(a, bc, m);
- cout << binpow(a, b, m) % m;
- }
- /*
- 2 2 2 2 10
- */
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- int t = 1;
- // cin >> t;
- while (t--)
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement