Submission #105262

#TimeUsernameProblemLanguageResultExecution timeMemory
105262he_____heTents (JOI18_tents)C++14
100 / 100
157 ms70904 KiB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int readint(){
	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;
}

const int cys=1000000007;
int n,m;
ll d[3005][3005];

int mod(int x){return x>=cys?x-cys:x;}

ll qpow(ll x,ll p){
	ll ret=1;
	for(;p;p>>=1,x=x*x%cys) if(p&1) ret=ret*x%cys;
	return ret;
}

int main(){
	n=readint(); m=readint();
	for(int i=0;i<=m;i++) d[0][i]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i) d[i][j]=d[i-1][j];
			if(i&&j) d[i][j]=mod(d[i][j]+4*j*d[i-1][j-1]%cys);
			if(i&&j>1) d[i][j]=mod(d[i][j]+(j*(j-1)/2)%cys*d[i-1][j-2]%cys);
			if(i>1&&j) d[i][j]=mod(d[i][j]+(i-1)*j%cys*d[i-2][j-1]%cys);
		}
	}
	printf("%lld\n",mod(d[n][m]+cys-1));
	return 0;
}

Compilation message (stderr)

tents.cpp: In function 'int main()':
tents.cpp:37:36: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
  printf("%lld\n",mod(d[n][m]+cys-1));
                  ~~~~~~~~~~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...