QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398623#6736. Alice and BobyeVegeTable#TL 0ms0kbC++201.7kb2024-04-25 15:53:152024-04-25 15:53:17

Judging History

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

  • [2024-04-25 15:53:17]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-25 15:53:15]
  • 提交

answer

#include <bits/stdc++.h>
#include <chrono>
using namespace std;
#define endl '\n'
//#define inf 1e18
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
typedef pair<ll, ll> P;
#define x first
#define y second
#define int long long

// const int p = 1e9 + 7;
const int pp = 998244353;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int ddx[8] = {1, 1, 2, 2, -1, -1, -2, -2}, ddy[8] = {2, -2, 1, -1, 2, -2, 1, -1};

ll ksm(ll a, ll b, ll p) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = (ans * a) % p;
        b >>= 1;
        a = (a * a) % p;
    }
    return ans % p;
}

std::mt19937 rng;  // 随机数生成器  
int rand(int l, int r) {
    std::uniform_int_distribution<int> distribution(l, r);
    return distribution(rng);
}

const int N = 1e7 + 1;
int f[N], g[N];
void init() {
    f[0] = g[0] = f[1] = g[1] = 1;
    for(int i = 2; i <= N; i++) {
        f[i] = f[i - 1] * i % pp;
        g[i] = g[i - 1] * ksm(i, pp - 2, pp) % pp;
    }
}

int C(int a, int b) {
    if(a < b) return 0;
    return f[a] * g[b] % pp * g[a - b] % pp;
}

void solve() {
    int n;
    cin >> n;
    int ans = 0;
    for(int p1 = 1; p1 <= n / 2 + 1; p1++) {
        int now = C(n - p1, p1 - 1) * f[p1 - 1] % pp * f[n - p1] % pp;
//         cout << "p1 : " << p1 << ", now : " << now << endl;
        ans = (ans + now) % pp;
    }
    cout << ans << endl;
}


/*	



*/

signed main () {
    // init(minp, primes, m); // primes
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    init();
    int _ = 1;
//   cin >> _;
    while(_ -- ) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:


result: