QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412540#6736. Alice and BobSunlight9#TL 993ms63132kbC++20662b2024-05-16 15:55:432024-05-16 15:55:43

Judging History

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

  • [2024-05-16 15:55:43]
  • 评测
  • 测评结果:TL
  • 用时:993ms
  • 内存:63132kb
  • [2024-05-16 15:55:43]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=1e7+7;
ll mod=998244353LL;
ll sum[MAXN];
int n;
inline ll ksm(ll x,ll y)
{
    ll res=1LL;
    while(y)
    {
        if(y&1LL) res=(res*x)%mod;
        x=(x*x)%mod;y=y>>1LL;
    }
    return res;
}
inline ll A(int x,int y)
{
    if(y>x) return 0;
    ll res=sum[x]*ksm(sum[x-y],mod-2LL);
    return res%mod;
}
int main()
{
    cin>>n;
    sum[0]=1LL;
    for(int i=1;i<=n;i++) sum[i]=(sum[i-1]*(ll) i)%mod;
    ll ans=0LL;
    for(int i=1;i<=n;i++)
    {
        ans+=A(n-i,i-1)*sum[n-i];
        ans%=mod;
    }
    cout<<ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3348kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

10

output:

997920

result:

ok 1 number(s): "997920"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3456kb

input:

100

output:

188898954

result:

ok 1 number(s): "188898954"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

4

output:

10

result:

ok 1 number(s): "10"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3384kb

input:

8

output:

12336

result:

ok 1 number(s): "12336"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

16

output:

373118483

result:

ok 1 number(s): "373118483"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3344kb

input:

32

output:

314585464

result:

ok 1 number(s): "314585464"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

64

output:

627827331

result:

ok 1 number(s): "627827331"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3344kb

input:

128

output:

828497685

result:

ok 1 number(s): "828497685"

Test #11:

score: 0
Accepted
time: 1ms
memory: 3384kb

input:

256

output:

65697890

result:

ok 1 number(s): "65697890"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

512

output:

854187619

result:

ok 1 number(s): "854187619"

Test #13:

score: 0
Accepted
time: 1ms
memory: 3496kb

input:

1024

output:

513823539

result:

ok 1 number(s): "513823539"

Test #14:

score: 0
Accepted
time: 179ms
memory: 15856kb

input:

1361956

output:

617368199

result:

ok 1 number(s): "617368199"

Test #15:

score: 0
Accepted
time: 993ms
memory: 63132kb

input:

7579013

output:

827172636

result:

ok 1 number(s): "827172636"

Test #16:

score: -100
Time Limit Exceeded

input:

8145517

output:

710624331

result: