QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#287882#5817. 小学生数学题lxkk0 0ms0kbC++14804b2023-12-21 09:06:262023-12-21 09:06:27

Judging History

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

  • [2023-12-21 09:06:27]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-12-21 09:06:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e7+10, MOD = 998244353;
int fac[N];

int f(int n)
{
    if(fac[n]) return fac[n];
    if(!n) return 1;
    fac[n] = (n % MOD * f(n - 1) % MOD) % MOD;
    return fac[n];
}

int quick_pow(int p, int q)
{
    int res = 1;
    while(q){
        if(q & 1) res = (res % MOD * p % MOD) % MOD;
        q >>= 1;
        p = (p % MOD * p % MOD) % MOD;
    }
    return res % MOD;
}

signed main()
{
    int n, k; cin >> n >> k;
    int res = 0;
    for(int i = 1; i <= N; i ++)
        fac[i] = f(i); 
        
    for(int i = 1; i <= n; i ++)
    {
        int fz = fac[i], fm = quick_pow(i, k);
        res += (fz % MOD * quick_pow(fm, MOD - 2) % MOD) % MOD;
    }
    cout << res << endl;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

9450395 1

output:


result:


Test #2:

score: 0
Time Limit Exceeded

input:

8978812 1

output:


result:


Test #3:

score: 0
Time Limit Exceeded

input:

8944235 1

output:


result:


Test #4:

score: 0
Time Limit Exceeded

input:

7081118 3

output:


result:


Test #5:

score: 0
Time Limit Exceeded

input:

7904241 3

output:


result:


Test #6:

score: 0
Time Limit Exceeded

input:

9921275 3

output:


result:


Test #7:

score: 0
Time Limit Exceeded

input:

17575748 14135489

output:


result:


Test #8:

score: 0
Time Limit Exceeded

input:

19858362 14822524

output:


result:


Test #9:

score: 0
Time Limit Exceeded

input:

18848696 15530895

output:


result:


Test #10:

score: 0
Time Limit Exceeded

input:

17787945 13890407

output:


result: