QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671510#5. 在线 O(1) 逆元QSteve_PaulCompile Error//C++23692b2024-10-24 13:03:482024-11-05 22:06:48

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 22:06:48]
  • 管理员手动重测本题所有提交记录
  • [2024-10-24 13:03:50]
  • 评测
  • [2024-10-24 13:03:48]
  • 提交

answer

#include <inv.h>

using i64 = long long;
constexpr int MAXN = 1e8 + 5;
constexpr int P = 998244353;

i64 qpow(i64 a, i64 n)
{
    i64 ans = 1;
    while (n)
    {
        if(n & 1)
            ans = ans * a % P;
        a = a * a % P;
        n >>= 1;
    }
    return ans;
}

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

int fac[MAXN];
int invfac[MAXN];

void init(int p)
{
    fac[0] = 1;
    for (i64 i = 1; i <= 1e8; i++)
        fac[i] = fac[i] * i % P;
    invfac[(int)1e8] = inv(fac[(int)1e8]);
    for (i64 i = 1e8 - 1; i >= 0; i--)
        invfac[i] = invfac[i + 1] * (i + 1) % P;
}

int inv(int x)
{
    return invfac[x] * fac[x - 1] % P;
}

详细

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:1:10: fatal error: inv.h: No such file or directory
    1 | #include <inv.h>
      |          ^~~~~~~
compilation terminated.