We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3f9998c commit eb4e7aaCopy full SHA for eb4e7aa
UVA/1230.cpp
@@ -0,0 +1,25 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+#define llong long long
4
+llong x, y, n;
5
+llong solve() {
6
+ llong res = 1 % n;
7
+ while (y > 0) {
8
+ if (y & 1)
9
+ res = res * x % n;
10
+ x = x * x % n;
11
+ y >>= 1;
12
+ }
13
+ return res;
14
+}
15
+int main(void) {
16
+ int NTEST = 0;
17
+ cin >> NTEST;
18
+ for(; NTEST; NTEST--) {
19
+ cin >> x >> y >> n;
20
+ llong ans = solve();
21
+ cout << ans << '\n';
22
23
+ int END;
24
+ cin >> END;
25
0 commit comments