Thirteen In Four Squarings
long long binpow(long long a, long long b, long long m) {
long long res = 1;
a %= m;
while (b > 0) {
if (b & 1) res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
cout << binpow(3, 13, 1000);
What does this print, and how many times does the line res = res * a % m; execute?
Sign in to answer questions and track your progress
Sign In