C - Reconciled?
设AA(x)为x的阶乘(对Mod求模),n与m相差为2则输出0,相差为1则输出AA(n)*AA(n)*2%Mod,相同则输出AA(n)*AA(m)%Mod,这题好粗心,把ans变量写成int,改成ll就对了,可是比赛时硬是检查不出来5555555555555555
#include <bits/stdc++.h> #define ll long long using namespace std; const int Mod = 1e9+7; ll AA(ll x){ ll ans = 1, i = 1; while(i <= x){ ans = (ans*i)%Mod; i++; } return ans%Mod; } int main(){ ll n,m; //cout << AA(100000) << endl; cin >> n >> m; if(abs(n-m) > 1){ cout << 0 << endl; return 0; } if(abs(n-m) == 1){ cout << (AA(n)*AA(m))%Mod << endl; }else { cout << ((AA(n)*2%Mod)*AA(m))%Mod << endl; } return 0; }