QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#449249#7018. Insertion SortHjccWA 3ms6732kbC++14913b2024-06-20 20:39:012024-06-20 20:39:02

Judging History

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

  • [2024-06-20 20:39:02]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6732kb
  • [2024-06-20 20:39:01]
  • 提交

answer

# include <bits/stdc++.h>
# define ll long long

using namespace std;

const int N = 2e5 + 5;
ll fac[N], ifac[N];
ll mod = 1e9 + 7;

ll qp(ll x, int y = mod - 2) {
  ll res = 1;
  for (; y; y >>= 1, x = x * x % mod) {
    if (y & 1) {
      res = res * x % mod;
    }
  }
  return res;
}

void init() {
  fac[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = fac[i - 1] * i % mod;
  }
  ifac[N - 1] = qp(fac[N - 1]);
  for (int i = N - 1; i; i--) {
    ifac[i - 1] = ifac[i] * i % mod;
  }
}

int main() {
# ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
# endif
  init();
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int T; cin >> T;
  for (int i = 1; i <= T; i++) {
    int n, k;
    cin >> n >> k >> mod;k = min(n, k);
    cout << "Case #" << i << ": " << fac[k] * (k * (n - k) + (n - k) * (n - k - 1) + (n - k) - (n - 1 - k)) % mod << '\n';
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 6732kb

input:

4
4 1 998244353
4 2 998244353
4 3 998244353
4 4 998244353

output:

Case #1: 10
Case #2: 14
Case #3: 24
Case #4: 24

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 6728kb

input:

5000
14 37 557911987
7 10 367410643
16 14 367486993
14 13 257679469
40 1 433152019
6 1 151926713
18 10 831429839
45 23 611504891
43 41 442772417
28 29 651920513
50 43 783397267
34 9 584271757
14 40 136299073
35 24 908302831
32 29 939394321
7 19 925472381
47 24 563986517
42 37 820968349
24 8 36281506...

output:

Case #1: 178290591
Case #2: 5040
Case #3: 14703426
Case #4: 86136984
Case #5: 1522
Case #6: 26
Case #7: 497145600
Case #8: 570622207
Case #9: 57451112
Case #10: 35757887
Case #11: 202298919
Case #12: 299738880
Case #13: 41991518
Case #14: 460920299
Case #15: 657816341
Case #16: 5040
Case #17: 470066...

result:

wrong answer 1st lines differ - expected: 'Case #1: 144021228', found: 'Case #1: 178290591'