Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
71113 sh25_wangtaojie 计算星期几 C++ 通过 0 MS 248 KB 844 2025-10-24 14:54:34

Tests(2/2):


#include <iostream> #include <string> using namespace std; // 快速幂取模函数 int fastPowerMod(int base, int exponent, int mod) { int 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; cin >> a >> b; // 计算a^b mod 7 int remainder = fastPowerMod(a, b, 7); // 今天是星期日(0),所以余数0对应周日,1对应周一,依此类推 string weekdays[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; // 输出结果 cout << weekdays[remainder] << endl; return 0; }


测评信息: