QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#139711 | #5406. 随机游走 | Lynkcat# | 35 | 115ms | 159956kb | C++17 | 1.1kb | 2023-08-14 11:28:08 | 2024-07-04 01:41:53 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 1000000007
#define sz(x) (int)((x).size())
#define int ll
#define N 10000005
using namespace std;
int n,fac[N],inv[N];
inline ll quickPower(ll x,ll y)
{
ll res=1;
while (y)
{
if (y&1) res=res*x%mod;
x=x*x%mod;
y>>=1;
}
return res;
}
inline int C(int x,int y)
{
if (x<y||y<0) return 0;
return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
void BellaKira()
{
cin>>n;
int ans=0;
for (int i=0;i<=n;i++)
{
if (i%2==0)
ans=(ans+2*inv[n+n+1]%mod*quickPower(n-i,n+n+1)%mod*C(n+n,i)%mod)%mod;
else
ans=(ans-2*inv[n+n+1]%mod*quickPower(n-i,n+n+1)%mod*C(n+n,i)%mod+mod)%mod;
}
cout<<ans<<'\n';
}
signed main()
{
fac[0]=1;
for (int i=1;i<N;i++) fac[i]=fac[i-1]*i%mod;
inv[N-1]=quickPower(fac[N-1],mod-2);
for (int i=N-1;i>=1;i--) inv[i-1]=inv[i]*i%mod;
IOS;
cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Checker Judgement Failed
Test #1:
score: 5
Accepted
time: 85ms
memory: 159908kb
input:
1
output:
333333336
result:
ok 1 number(s): "168974634"
Test #2:
score: 0
Accepted
time: 82ms
memory: 159792kb
input:
2
output:
266666669
result:
ok 1 number(s): "266666669"
Test #3:
score: -5
Checker Judgement Failed
input:
3
output:
769047625
result:
Subtask #2:
score: 10
Accepted
Test #4:
score: 10
Accepted
time: 92ms
memory: 159840kb
input:
4
output:
877865968
result:
ok 1 number(s): "877865968"
Test #5:
score: 0
Accepted
time: 92ms
memory: 159904kb
input:
5
output:
733342859
result:
ok 1 number(s): "733342859"
Test #6:
score: 0
Accepted
time: 79ms
memory: 159952kb
input:
6
output:
655899114
result:
Test #7:
score: 0
Accepted
time: 99ms
memory: 159912kb
input:
7
output:
946326757
result:
ok 1 number(s): "946326757"
Test #8:
score: 0
Accepted
time: 96ms
memory: 159840kb
input:
8
output:
230714822
result:
ok 1 number(s): "230714822"
Test #9:
score: 0
Accepted
time: 100ms
memory: 159840kb
input:
9
output:
782967541
result:
ok 1 number(s): "255062346"
Test #10:
score: 0
Accepted
time: 87ms
memory: 159828kb
input:
10
output:
732371611
result:
ok 1 number(s): "732371611"
Subtask #3:
score: 10
Accepted
Test #11:
score: 10
Accepted
time: 78ms
memory: 159844kb
input:
15
output:
677123472
result:
ok 1 number(s): "677123472"
Test #12:
score: 0
Accepted
time: 92ms
memory: 159896kb
input:
13
output:
168974634
result:
ok 1 number(s): "168974634"
Test #13:
score: 0
Accepted
time: 87ms
memory: 159836kb
input:
26
output:
213343876
result:
ok 1 number(s): "213343876"
Test #14:
score: 0
Accepted
time: 90ms
memory: 159872kb
input:
29
output:
631124616
result:
Subtask #4:
score: 0
Checker Judgement Failed
Test #15:
score: 0
Checker Judgement Failed
input:
37
output:
349256161
result:
Subtask #5:
score: 0
Checker Judgement Failed
Test #20:
score: 0
Checker Judgement Failed
input:
562
output:
255062346
result:
Subtask #6:
score: 15
Accepted
Test #26:
score: 15
Accepted
time: 84ms
memory: 159880kb
input:
3946
output:
977435333
result:
ok 1 number(s): "977435333"
Test #27:
score: 0
Accepted
time: 94ms
memory: 159840kb
input:
65944
output:
312666196
result:
ok 1 number(s): "312666196"
Test #28:
score: 0
Accepted
time: 107ms
memory: 159912kb
input:
163815
output:
163767254
result:
ok 1 number(s): "163767254"
Test #29:
score: 0
Accepted
time: 115ms
memory: 159896kb
input:
198732
output:
911833524
result:
ok 1 number(s): "911833524"
Test #30:
score: 0
Accepted
time: 99ms
memory: 159956kb
input:
199287
output:
910277128
result:
ok 1 number(s): "910277128"
Test #31:
score: 0
Accepted
time: 101ms
memory: 159908kb
input:
199819
output:
561747634
result:
ok 1 number(s): "561747634"
Subtask #7:
score: 0
Checker Judgement Failed
Test #32:
score: 0
Checker Judgement Failed
input:
315618
output:
602805814