QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#91269 | #5817. 小学生数学题 | skittles1412 | 20 | 895ms | 3512kb | C++17 | 1.2kb | 2023-03-28 08:00:16 | 2023-03-28 08:00:19 |
Judging History
answer
#include "bits/extc++.h"
using namespace std;
template <typename T>
void dbgh(const T& t) {
cerr << t << endl;
}
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t << " | ";
dbgh(u...);
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \
<< ": "; \
dbgh(__VA_ARGS__)
#else
#define cerr \
if (false) \
cerr
#define dbg(...)
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))
constexpr long mod = 998244353;
long bpow(long base, long exp) {
long ans = 1;
while (exp) {
if (exp & 1) {
ans = (ans * base) % mod;
}
base = (base * base) % mod;
exp >>= 1;
}
return ans;
}
void solve() {
int n, k;
cin >> n >> k;
long fact = 1, ans = 0;
for (int i = 1; i <= n; i++) {
fact = (fact * i) % mod;
ans = (ans + fact * bpow(i, mod - 1 - k)) % mod;
}
cout << ans << endl;
}
int main() {
cin.tie(nullptr);
cin.exceptions(ios::failbit);
ios_base::sync_with_stdio(false);
solve();
}
詳細信息
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: 10
Accepted
time: 801ms
memory: 3512kb
input:
7081118 3
output:
599009773
result:
ok single line: '599009773'
Test #5:
score: 10
Accepted
time: 895ms
memory: 3336kb
input:
7904241 3
output:
871243720
result:
ok single line: '871243720'
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