QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#705418#5. 在线 O(1) 逆元lvliangCompile Error//C++14347b2024-11-02 23:24:502024-11-05 22:07:54

Judging History

This is the latest submission verdict.

  • [2024-11-05 22:07:54]
  • 管理员手动重测本题所有提交记录
  • [2024-11-02 23:24:51]
  • Judged
  • [2024-11-02 23:24:50]
  • Submitted

answer

int quickPow(int base, int power, int mod) {
    int result = 1;
    base = base % mod;
    while (power > 0) {
        if (power & 1) {
            result = (result * base) % mod;
        }
        base = (base * base) % mod;
        power >>= 1;
    }
    return result;
}

int inv(int x) {
    return quickPow(x, MOD - 2, MOD);
}

詳細信息

implementer.cpp: In function ‘int main()’:
implementer.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
answer.code: In function ‘int inv(int)’:
answer.code:15:24: error: ‘MOD’ was not declared in this scope
   15 |     return quickPow(x, MOD - 2, MOD);
      |                        ^~~