QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#139710#5406. 随机游走Lynkcat#60 497ms159964kbC++171.1kb2023-08-14 11:27:582024-07-04 01:41:52

Judging History

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

  • [2024-07-04 01:41:52]
  • 评测
  • 测评结果:60
  • 用时:497ms
  • 内存:159964kb
  • [2023-08-14 11:27:58]
  • 提交

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 5000005
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: 5
Accepted

Test #1:

score: 5
Accepted
time: 45ms
memory: 81764kb

input:

1

output:

333333336

result:

ok 1 number(s): "333333336"

Test #2:

score: 0
Accepted
time: 39ms
memory: 81804kb

input:

2

output:

266666669

result:

ok 1 number(s): "266666669"

Test #3:

score: 0
Accepted
time: 36ms
memory: 81708kb

input:

3

output:

769047625

result:

ok 1 number(s): "769047625"

Subtask #2:

score: 0
Runtime Error

Test #4:

score: 10
Accepted
time: 40ms
memory: 81708kb

input:

4

output:

877865968

result:

ok 1 number(s): "877865968"

Test #5:

score: 0
Accepted
time: 52ms
memory: 81772kb

input:

5

output:

733342859

result:

ok 1 number(s): "733342859"

Test #6:

score: 0
Accepted
time: 41ms
memory: 81768kb

input:

6

output:

655899114

result:

ok 1 number(s): "655899114"

Test #7:

score: 0
Accepted
time: 40ms
memory: 81776kb

input:

7

output:

946326757

result:

ok 1 number(s): "946326757"

Test #8:

score: 0
Accepted
time: 37ms
memory: 81772kb

input:

8

output:

230714822

result:

ok 1 number(s): "230714822"

Test #9:

score: -10
Runtime Error

input:

9

output:


result:


Subtask #3:

score: 10
Accepted

Test #11:

score: 10
Accepted
time: 95ms
memory: 159892kb

input:

15

output:

677123472

result:

ok 1 number(s): "677123472"

Test #12:

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

input:

13

output:

168974634

result:

ok 1 number(s): "168974634"

Test #13:

score: 0
Accepted
time: 96ms
memory: 159816kb

input:

26

output:

213343876

result:

ok 1 number(s): "266666669"

Test #14:

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

input:

29

output:

631124616

result:

ok 1 number(s): "631124616"

Subtask #4:

score: 15
Accepted

Test #15:

score: 15
Accepted
time: 88ms
memory: 159828kb

input:

37

output:

349256161

result:

ok 1 number(s): "349256161"

Test #16:

score: 0
Accepted
time: 90ms
memory: 159844kb

input:

104

output:

351095881

result:

ok 1 number(s): "351095881"

Test #17:

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

input:

194

output:

895504391

result:

ok 1 number(s): "895504391"

Test #18:

score: 0
Accepted
time: 91ms
memory: 159964kb

input:

197

output:

923555376

result:

ok 1 number(s): "923555376"

Test #19:

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

input:

198

output:

512220517

result:

ok 1 number(s): "512220517"

Subtask #5:

score: 15
Accepted

Test #20:

score: 15
Accepted
time: 94ms
memory: 159964kb

input:

562

output:

255062346

result:

ok 1 number(s): "255062346"

Test #21:

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

input:

1007

output:

735041605

result:

ok 1 number(s): "732371611"

Test #22:

score: 0
Accepted
time: 83ms
memory: 159908kb

input:

1788

output:

208261384

result:

ok 1 number(s): "677123472"

Test #23:

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

input:

1980

output:

875427987

result:

ok 1 number(s): "875427987"

Test #24:

score: 0
Accepted
time: 91ms
memory: 159956kb

input:

1983

output:

571776252

result:

ok 1 number(s): "571776252"

Test #25:

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

input:

1992

output:

12983695

result:

ok 1 number(s): "12983695"

Subtask #6:

score: 15
Accepted

Test #26:

score: 15
Accepted
time: 94ms
memory: 159912kb

input:

3946

output:

977435333

result:

ok 1 number(s): "977435333"

Test #27:

score: 0
Accepted
time: 98ms
memory: 159840kb

input:

65944

output:

312666196

result:

ok 1 number(s): "312666196"

Test #28:

score: 0
Accepted
time: 94ms
memory: 159908kb

input:

163815

output:

163767254

result:

ok 1 number(s): "163767254"

Test #29:

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

input:

198732

output:

911833524

result:

ok 1 number(s): "911833524"

Test #30:

score: 0
Accepted
time: 103ms
memory: 159956kb

input:

199287

output:

910277128

result:

ok 1 number(s): "910277128"

Test #31:

score: 0
Accepted
time: 112ms
memory: 159900kb

input:

199819

output:

561747634

result:

ok 1 number(s): "561747634"

Subtask #7:

score: 0
Wrong Answer

Test #32:

score: 30
Accepted
time: 113ms
memory: 159892kb

input:

315618

output:

602805814

result:

ok 1 number(s): "602805814"

Test #33:

score: 0
Accepted
time: 213ms
memory: 159904kb

input:

1130465

output:

898203793

result:

ok 1 number(s): "898203793"

Test #34:

score: -30
Wrong Answer
time: 497ms
memory: 159892kb

input:

4399723

output:


result:

wrong output format Output file not found: ""