QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#399939#6736. Alice and Bob001#AC ✓171ms394328kbC++111.6kb2024-04-26 20:01:492024-04-26 20:01:50

Judging History

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

  • [2024-04-26 20:01:50]
  • 评测
  • 测评结果:AC
  • 用时:171ms
  • 内存:394328kb
  • [2024-04-26 20:01:49]
  • 提交

answer

//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<stdio.h>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>
#include<unordered_map>
using namespace std;
#define int long long
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')f=-1;
        ch=getchar();
    }while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0',ch=getchar();
    }return x*f;
}
void write(int x){
    if(x<0)putchar('-');
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
const int inf=0x3f3f3f3f3f3f3f3f;
const int N=1e7+5,M=500+5;
const int mod=998244353;
typedef pair<int,int>pii;
int T,n,m,x,y,l,r;
int mn=inf;
int rt;
vector<int>nd[N];
int fac[N],ifac[N];
int quickp(int base,int pow=mod-2){
    int res=1;
    while(pow){
        if(pow&1){
            res=res*base%mod;
        }pow>>=1;
        base=base*base%mod;
    }return res;
}
void init(){
    fac[0]=ifac[0]=1;
    for(int i=1;i<N;i++){
        fac[i]=fac[i-1]*i%mod;
    }ifac[N-1]=quickp(fac[N-1]);
    for(int i=N-2;i;i--)ifac[i]=ifac[i+1]*(i+1)%mod;
}
int C(int n,int m){
    if(n<m)return 0;
    return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
signed main(){

    //T=read();
    init();
    T=1;
    while(T--){
        n=read();
        int r=0;
        for(int i=1;i<=n;i++){
            //if(i-1>n-i)break;
            r=(r+C(n-i,i-1)*fac[i-1]%mod*fac[n-i])%mod;
            //r=(r+fac[i-1])%mod;
            //printf("%lld r:%lld\n",C(n-i,i-1)*fac[i-1],r);
        }write(r);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 130ms
memory: 394164kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 93ms
memory: 394244kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 119ms
memory: 394300kb

input:

10

output:

997920

result:

ok 1 number(s): "997920"

Test #4:

score: 0
Accepted
time: 118ms
memory: 394308kb

input:

100

output:

188898954

result:

ok 1 number(s): "188898954"

Test #5:

score: 0
Accepted
time: 114ms
memory: 394184kb

input:

4

output:

10

result:

ok 1 number(s): "10"

Test #6:

score: 0
Accepted
time: 132ms
memory: 394252kb

input:

8

output:

12336

result:

ok 1 number(s): "12336"

Test #7:

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

input:

16

output:

373118483

result:

ok 1 number(s): "373118483"

Test #8:

score: 0
Accepted
time: 127ms
memory: 394256kb

input:

32

output:

314585464

result:

ok 1 number(s): "314585464"

Test #9:

score: 0
Accepted
time: 79ms
memory: 394308kb

input:

64

output:

627827331

result:

ok 1 number(s): "627827331"

Test #10:

score: 0
Accepted
time: 122ms
memory: 394152kb

input:

128

output:

828497685

result:

ok 1 number(s): "828497685"

Test #11:

score: 0
Accepted
time: 110ms
memory: 394276kb

input:

256

output:

65697890

result:

ok 1 number(s): "65697890"

Test #12:

score: 0
Accepted
time: 114ms
memory: 394312kb

input:

512

output:

854187619

result:

ok 1 number(s): "854187619"

Test #13:

score: 0
Accepted
time: 120ms
memory: 394244kb

input:

1024

output:

513823539

result:

ok 1 number(s): "513823539"

Test #14:

score: 0
Accepted
time: 130ms
memory: 394168kb

input:

1361956

output:

617368199

result:

ok 1 number(s): "617368199"

Test #15:

score: 0
Accepted
time: 157ms
memory: 394260kb

input:

7579013

output:

827172636

result:

ok 1 number(s): "827172636"

Test #16:

score: 0
Accepted
time: 139ms
memory: 394168kb

input:

8145517

output:

710624331

result:

ok 1 number(s): "710624331"

Test #17:

score: 0
Accepted
time: 151ms
memory: 394308kb

input:

6140463

output:

707600568

result:

ok 1 number(s): "707600568"

Test #18:

score: 0
Accepted
time: 120ms
memory: 394248kb

input:

3515281

output:

698302413

result:

ok 1 number(s): "698302413"

Test #19:

score: 0
Accepted
time: 136ms
memory: 394244kb

input:

6969586

output:

69470392

result:

ok 1 number(s): "69470392"

Test #20:

score: 0
Accepted
time: 123ms
memory: 394244kb

input:

2888636

output:

433579983

result:

ok 1 number(s): "433579983"

Test #21:

score: 0
Accepted
time: 171ms
memory: 394328kb

input:

9999998

output:

758172780

result:

ok 1 number(s): "758172780"

Test #22:

score: 0
Accepted
time: 153ms
memory: 394172kb

input:

9999999

output:

605195495

result:

ok 1 number(s): "605195495"

Test #23:

score: 0
Accepted
time: 168ms
memory: 394168kb

input:

10000000

output:

866813682

result:

ok 1 number(s): "866813682"