QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#566555#5. 在线 O(1) 逆元yihang_01Compile Error//C++20298b2024-09-16 00:30:142024-09-16 00:30:14

Judging History

你现在查看的是测评时间为 2024-09-16 00:30:14 的历史记录

  • [2024-11-05 22:03:47]
  • 管理员手动重测本题所有提交记录
  • [2024-09-16 00:30:14]
  • 评测
  • [2024-09-16 00:30:14]
  • 提交

answer

using i64 = long long;

i64 mod;

i64 qpow(i64 a, i64 b) {
    i64 res = 1;
    while(b) {
        if(b&1) res = (res * a) % mod;
        a = (a*a) %mod;
        b >>= 1;
    }

    return res;
}

void init(int p) {
    mod = p;
}

i64 inv(i64 a) {
    return qpow(a, mod-2);
}

詳細信息

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);
      |         ~~~~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccMdegiy.o: in function `main':
implementer.cpp:(.text.startup+0x1d0): undefined reference to `inv(int)'
collect2: error: ld returned 1 exit status