pastebin

Paste Search Dynamic
Recent pastes
dcmp
  1. #define _CRT_SECURE_NO_DEPRECATE
  2. #include <bits/stdc++.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <utility>
  6. #include <limits>
  7.  
  8. #define pb                  push_back
  9. #define ppb                 pop_back
  10. #define fixed(n)        fixed << setprecision(n)
  11. #define mp                  make_pair
  12. #define loop(i, st, en)         for(int i = st; i < en; i++)
  13. #define pool(i, st)             for(int i = st; i >= 0; i--)
  14. #define ii                              pair<int, int>
  15. #define vii                     vector<ii>
  16. #define vi                              vector<int>
  17. #define vv                  vector<vi>
  18. #define all(v)                          ((v).begin()), ((v).end())
  19. #define sz(v)                           ((int)((v).size()))
  20. #define zero(v)             memset(v, 0, sizeof(v))
  21. #define rep(i, v)                       for(int i = 0; i < sz(v); ++i)
  22. #define fr                                  first
  23. #define sec                             second
  24. #define INF                             (1e9+7)
  25. #define NetroMood                       ios_base::sync_with_stdio(false);cin.tie(NULL);
  26. #define intINF                          numric_limits<int>::max();
  27. #define TC                      int t; cin >> t;   while(t--)
  28. using namespace std;
  29. typedef long long ll;
  30. typedef unsigned long long ull;
  31. typedef long double lld;
  32. const int MOD = 1000000007;
  33. const double EPS = (1e-7);
  34. //double pi = M_PI;
  35. #ifndef ONLINE_JUDGE
  36. #define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
  37. #else
  38. #define debug(x)
  39. #endif
  40.  
  41. void _print(ll t) {cerr << t;}
  42. void _print(int t) {cerr << t;}
  43. void _print(string t) {cerr << t;}
  44. void _print(char t) {cerr << t;}
  45. void _print(lld t) {cerr << t;}
  46. void _print(double t) {cerr << t;}
  47. void _print(ull t) {cerr << t;}
  48.  
  49. template <class T, class V> void _print(pair <T, V> p);
  50. template <class T> void _print(vector <T> v);
  51. template <class T> void _print(set <T> v);
  52. template <class T, class V> void _print(map <T, V> v);
  53. template <class T> void _print(multiset <T> v);
  54. template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.fr); cerr << ","; _print(p.sec); cerr << "}";}
  55. template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  56. template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  57. template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  58. template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
  59.  
  60. int dx[8] = {0,0,1,-1,1,-1,1,-1};
  61. int dy[8] = {1,-1,0,0,1,-1,-1,1};
  62. int n, tt, x;
  63. char ch;
  64. int dcmp(double x, double y) {  return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;   }
  65.  
  66.  
  67. ll fastb(ll a, ll b, ll m) {
  68.     ll res = 1;
  69.     while(b) {
  70.         if(b%2)
  71.             res = (res*a) % m;
  72.         a = (a * a)%m;
  73.         b /= 2;
  74.     }
  75.     return res;
  76. }
  77. int main()
  78. {
  79.     NetroMood
  80.     #ifndef ONLINE_JUDGE
  81.     freopen("debug.txt", "w", stderr);
  82.     // freopen("tests.txt", "r", stdin);
  83.     //freopen("output.txt", "w", stdout);
  84.     #endif
  85.  
  86.     ll a, b, m;
  87.     cin >> a >> b >> m;
  88.     cout << fastb(a, b, m) << "n";
  89. }
  90.  
Parsed in 0.069 seconds