QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#91269#5817. 小学生数学题skittles141220 895ms3512kbC++171.2kb2023-03-28 08:00:162023-03-28 08:00:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-28 08:00:19]
  • 评测
  • 测评结果:20
  • 用时:895ms
  • 内存:3512kb
  • [2023-03-28 08:00:16]
  • 提交

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

output:


result: