在湖蓝跟衡水大佬们打的第二场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);
}
View Code

相关文章:

  • 2021-06-29
  • 2021-10-26
  • 2022-02-03
  • 2021-11-08
  • 2021-12-23
  • 2022-02-07
  • 2021-09-17
  • 2022-02-07
猜你喜欢
  • 2021-09-06
  • 2022-02-26
  • 2021-07-16
  • 2022-12-23
  • 2021-02-21
  • 2021-11-17
相关资源
相似解决方案