QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#449280#7018. Insertion SortSampsonYWWA 0ms3956kbC++141.6kb2024-06-20 21:23:022024-06-20 21:23:02

Judging History

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

  • [2024-06-20 21:23:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3956kb
  • [2024-06-20 21:23:02]
  • 提交

answer

#include <bits/stdc++.h>
#define db double
#define il inline
#define re register
#define ll long long
#define ui unsigned
#define ull ui ll
#define i128 __int128
#define pii pair<int, int>
#define fi first
#define se second
#define eb emplace_back
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define mems(v, x) memset(v, x, sizeof(v))
#define memc(a, b) memcpy(a, b, sizeof(a))
#define FOR(i, L, R) for(re int i = (L); i <= (R); ++i)
#define ROF(i, R, L) for(re int i = (R); i >= (L); --i)
#define LS i << 1, l, mid
#define RS i << 1 | 1, mid + 1, r
#define popc(x) __builtin_popcount(x)
#define popcll(x) __builtin_popcountll(x)
using namespace std;
#define N 400005
// #define P 998244353
int P;
il int add(int x, int y) {return x + y < P ? x + y : x + y - P;}
il void addr(int &x, int y) {(x += y) >= P && (x -= P);}
il int qpow(int p, ll n = P - 2) {
  int s = 1;
  while(n) {
    if(n & 1) s = 1ll * s * p % P;
    p = 1ll * p * p % P, n >>= 1;
  }
  return s;
}
template<class T> il void chkmin(T &x, T y) {if(x > y) x = y;}
template<class T> il void chkmax(T &x, T y) {if(x < y) x = y;}
int n, m, T;
int fac[N];
il void WORK() {
  cin >> n >> m >> P;
  fac[0] = 1; FOR(i, 1, n) fac[i] = 1ll * fac[i - 1] * i % P;
  chkmin(m, n); if(m == n || m == n - 1) {cout << "CASE #" << ++T << ": " << fac[n] << "\n"; return ;}
  int k = n - m;
  cout << "CASE #" << ++T << ": " << 1ll * fac[m] * (k * (k - 1) - (k - 2) + m * k + k - 1) % P << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int T; cin >> T;
  while(T--) WORK();
  cerr << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
  return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3956kb

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:

wrong answer 1st lines differ - expected: 'Case #1: 10', found: 'CASE #1: 10'