题目

【快速幂取模】代码
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>#include <cctype>using namespace std;
long long pow_mod(long long base, long long exponent, long long mod) {long long result = 1;base %= mod;while (exponent > 0) {if (exponent % 2 == 1) {result = (result * base) % mod;}base = (base * base) % mod;exponent /= 2;}return result;
}int main() {int a, b, n;cin >> a >> b >> n;int mod = b * 1000;int res = a * pow_mod(10, n + 2, mod) % mod / b;printf("%03d", res);return 0;
}
快速幂模板代码
#include <iostream>
using namespace std;long long pow_mod(long long base, long long n ) {long long r = 1;while (n > 0) {if (n % 2 == 1)r = r * base;base *= base;n /= 2;}return r;
}int main() {cout << pow_mod(2, 10);return 0;
}