Saleh127

uva 374.cpp

Jun 7th, 2020 (edited)
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. #define pi acos(-1)
  7. #define yes printf("YES\n");
  8. #define no printf("NO\n");
  9. ll bigmod(ll a,ll c,ll d)
  10. {
  11. if(c==0) return 1LL;
  12. ll x=bigmod(a,c/2,d);
  13. x=(x*x)%d;
  14. if(c%2==1LL)
  15. {
  16. x=(x*a)%d;
  17. }
  18. return x;
  19. }
  20. int main()
  21. {
  22. Faster
  23. ll a,c,d,md;
  24. while(cin>>a>>c>>d)
  25. {
  26. md=bigmod(a,c,d);
  27. cout<<md<<endl;
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment