Code:
#include<bits/stdc++.h> #define maxn 10003 #define ll long long #define p 10000000000ll using namespace std; ll base[maxn]; int n,m,len=1; void multiply(int x) { ll pre=0,tmp; for(int i=1;i<=len;i++) { tmp=base[i]*x; base[i]=tmp%p+pre; pre=tmp/p; } if(pre)++len, base[len]=pre; } int main(){ scanf("%d%d",&n,&m); base[1]=1; for(int i=1;i<=n;i++)multiply(i); for(int i=n-m+4;i<=n+2;i++)multiply(i); multiply(n+1); multiply(n*(n+3)+2*m); printf("%lld",base[len]); while(--len)printf("%010lld",base[len]); return 0; }