QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#189074#6736. Alice and Bobzwp1234AC ✓106ms159856kbC++172.5kb2023-09-26 20:29:232023-09-26 20:29:24

Judging History

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

  • [2023-09-26 20:29:24]
  • 评测
  • 测评结果:AC
  • 用时:106ms
  • 内存:159856kb
  • [2023-09-26 20:29:23]
  • 提交

answer

//# pragma GCC optimize(2)
#include <bits/stdc++.h>
#define int long long
#define SZ(x) (int)(x).size()
#define fs first
#define sc second
#define PII pair<int,int>
#define ls(u) (u)<<1
#define rs(u) (u)<<1|1
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vi >
#define vI vector<PII>
#define db double
#define all(a) (a).begin(),(a).end()
#define lowbit(x) (x)&(-x)
#define die cout << "???" << endl
//#define endl '\n'
using namespace std;
const int mod = 998244353;
//const int mod = 1169996969;
//const int mod = 1e9 + 7;
//const int inf = LLONG_MAX;
const int inf = 0x3f3f3f3f;
//const int inf = 1e9;
//const db PI = acos(-1.0);
const db eps = 1e-7;
typedef long long ll;
typedef unsigned long long  ull;
const int N = 1e7+5,M = 2e6+5,K = 20;

inline int rd() {
    int f = 0; int x = 0; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
    if (f) x = -x;
    return x;
}

void write(ll a) {if(a>=10)write(a/10);putchar(a%10+'0');}
void wt(ll a) {if(a < 0) {putchar('-');a = -a;}write(a);}
void wwt(ll a){wt(a);putchar('\n');}

// int mul(int x, int y, int p)
// {
//     int z = (long double)x / p * y;
//     ll res = (unsigned long long)x * y - (unsigned long long) z * p;
//     return (res + p) % p;
// }

int n,m,k;

template<class T> inline bool smin(T &x,T y) {return x > y?x = y,1:0;}
template<class T> inline bool smax(T &x,T y) {return x < y?x = y,1:0;}

inline int add(int x,int y) {return x + y >= mod?x + y - mod:x+y;}

int fac[N],invf[N];

int fsm(int b,int p)
{
    int res = 1;
    while(p)
    {
        if(p&1) res = res*b%mod;
        b = b*b%mod;
        p >>= 1;
    }

    return res;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r+", stdin);
    freopen("out.txt", "w+", stdout);
    #endif

    fac[0] = fac[1] = 1;
    invf[0] = invf[1] = 1;

    for(int i = 2;i<N;i++)
    {
        fac[i] = fac[i-1]*i%mod;
    }

    invf[N-1] = fsm(fac[N-1],mod-2);

    for(int i = N-2;i;i--)
    {
        invf[i] = invf[i+1]*(i+1)%mod; 
    }

    cin >> n;

    int ans = 0;

    for(int i = 1;n - i >= i - 1;i++)
    {
        int tmp = fac[n-i]*fac[n-i]%mod*invf[n+1 - i*2]%mod;
        ans = add(ans,tmp);
    }

    cout << ans;

    return 0;   
}


// 26 26
// 34 34
// 23 36
// 34 43
// 31 31

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 71ms
memory: 159820kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 71ms
memory: 159640kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 80ms
memory: 159804kb

input:

10

output:

997920

result:

ok 1 number(s): "997920"

Test #4:

score: 0
Accepted
time: 77ms
memory: 159856kb

input:

100

output:

188898954

result:

ok 1 number(s): "188898954"

Test #5:

score: 0
Accepted
time: 61ms
memory: 159808kb

input:

4

output:

10

result:

ok 1 number(s): "10"

Test #6:

score: 0
Accepted
time: 84ms
memory: 159852kb

input:

8

output:

12336

result:

ok 1 number(s): "12336"

Test #7:

score: 0
Accepted
time: 63ms
memory: 159628kb

input:

16

output:

373118483

result:

ok 1 number(s): "373118483"

Test #8:

score: 0
Accepted
time: 78ms
memory: 159692kb

input:

32

output:

314585464

result:

ok 1 number(s): "314585464"

Test #9:

score: 0
Accepted
time: 84ms
memory: 159648kb

input:

64

output:

627827331

result:

ok 1 number(s): "627827331"

Test #10:

score: 0
Accepted
time: 78ms
memory: 159712kb

input:

128

output:

828497685

result:

ok 1 number(s): "828497685"

Test #11:

score: 0
Accepted
time: 58ms
memory: 159696kb

input:

256

output:

65697890

result:

ok 1 number(s): "65697890"

Test #12:

score: 0
Accepted
time: 84ms
memory: 159684kb

input:

512

output:

854187619

result:

ok 1 number(s): "854187619"

Test #13:

score: 0
Accepted
time: 63ms
memory: 159696kb

input:

1024

output:

513823539

result:

ok 1 number(s): "513823539"

Test #14:

score: 0
Accepted
time: 89ms
memory: 159780kb

input:

1361956

output:

617368199

result:

ok 1 number(s): "617368199"

Test #15:

score: 0
Accepted
time: 106ms
memory: 159720kb

input:

7579013

output:

827172636

result:

ok 1 number(s): "827172636"

Test #16:

score: 0
Accepted
time: 105ms
memory: 159720kb

input:

8145517

output:

710624331

result:

ok 1 number(s): "710624331"

Test #17:

score: 0
Accepted
time: 99ms
memory: 159824kb

input:

6140463

output:

707600568

result:

ok 1 number(s): "707600568"

Test #18:

score: 0
Accepted
time: 64ms
memory: 159788kb

input:

3515281

output:

698302413

result:

ok 1 number(s): "698302413"

Test #19:

score: 0
Accepted
time: 87ms
memory: 159776kb

input:

6969586

output:

69470392

result:

ok 1 number(s): "69470392"

Test #20:

score: 0
Accepted
time: 92ms
memory: 159696kb

input:

2888636

output:

433579983

result:

ok 1 number(s): "433579983"

Test #21:

score: 0
Accepted
time: 89ms
memory: 159700kb

input:

9999998

output:

758172780

result:

ok 1 number(s): "758172780"

Test #22:

score: 0
Accepted
time: 85ms
memory: 159684kb

input:

9999999

output:

605195495

result:

ok 1 number(s): "605195495"

Test #23:

score: 0
Accepted
time: 84ms
memory: 159680kb

input:

10000000

output:

866813682

result:

ok 1 number(s): "866813682"