QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478499#8483. Count the Christmas Treesrania__#WA 2ms11672kbC++231.0kb2024-07-15 02:53:372024-07-15 02:53:38

Judging History

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

  • [2024-07-15 02:53:38]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:11672kb
  • [2024-07-15 02:53:37]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define double long double
#define f first
#define s second
#define pb push_back
#define pp push
#define ceill(x,y) ((x/y)+(x%y!=0)*(x/abs(x)*y/abs(y)<0?0:1))
#define floorr(x,y) ((x/y)+(x%y!=0)*(x/abs(x)*y/abs(y)<0?-1:0))
#define YN(x) cout<<(x?"YES\n":"NO\n");
#define Yn(x) cout<<(x?"Yes\n":"No\n");
#define yn(x) cout<<(x?"yes\n":"no\n");
const int MAAX=1e18;
const int MOD=1e9+7;
const int MAX=1e9;

int dp[1010][1010];
int fun(int lft,int sum){
	if(lft==0)
		return sum==0;
	if(sum<0)
		return 0;
	int &ret=dp[lft][sum];
	if(~ret)
		return ret;
	return ret=(fun(lft-1,sum)+fun(lft-1,sum-1)+fun(lft-1,sum-2))%MOD;
}

in main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int tc=1;
    // cin>>tc;
    while(tc--){
    	memset(dp,-1,sizeof dp);
		int n;
		cin>>n;
		int ans=1;
		for(int i=1;i<n;i++)
			ans*=fun(i,i+1);
		cout<<ans<<"\n";
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 11668kb

input:

3

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

4

output:

12

result:

ok 1 number(s): "12"

Test #3:

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

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 2ms
memory: 11592kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 2ms
memory: 11616kb

input:

5

output:

192

result:

ok 1 number(s): "192"

Test #6:

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

input:

6

output:

8640

result:

ok 1 number(s): "8640"

Test #7:

score: 0
Accepted
time: 2ms
memory: 11592kb

input:

7

output:

1088640

result:

ok 1 number(s): "1088640"

Test #8:

score: 0
Accepted
time: 2ms
memory: 11588kb

input:

8

output:

388644480

result:

ok 1 number(s): "388644480"

Test #9:

score: -100
Wrong Answer
time: 1ms
memory: 11672kb

input:

9

output:

394862791680

result:

wrong answer 1st numbers differ - expected: '862788922', found: '394862791680'