在湖蓝跟衡水大佬们打的第二场atcoder,不知不觉一星期都过去了。
C - Reconciled?
题意:n只猫,m只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方案。
#include<cstdio> #include<algorithm> using namespace std; const int MOD=1e9+7; int n,m,mmh=1; int main(){ scanf("%d%d",&n,&m); if (n<m) swap(n,m); if (n-m>1) return puts("0"),0; for (int i=1;i<=n;i++) mmh=1LL*mmh*i%MOD; for (int i=1;i<=m;i++) mmh=1LL*mmh*i%MOD; if (n==m) mmh=mmh*2%MOD; printf("%d\n",mmh); }