QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#287882 | #5817. 小学生数学题 | lxkk | 0 | 0ms | 0kb | C++14 | 804b | 2023-12-21 09:06:26 | 2023-12-21 09:06:27 |
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