Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
76498 sh25_wanghy 幂的末尾 C++ 通过 0 MS 244 KB 543 2025-12-19 15:14:06

Tests(1/1):


#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; }


测评信息: