提交时间:2025-12-19 15:14:06

运行 ID: 76498

#include <iostream> #include <iomanip> using namespace std; int main() { int a, b; cin >> a >> b; int result = 1; int base = a % 1000; // 只关心末三位 // 快速幂算法计算a^b mod 1000 while (b > 0) { if (b % 2 == 1) { result = (result * base) % 1000; } base = (base * base) % 1000; b /= 2; } // 输出末三位,不足三位时前面补零 cout << setw(3) << setfill('0') << result << endl; return 0; }