Last active
June 29, 2018 08:12
-
-
Save sadmiko/68ac4167533877e87350c9e7be6c004a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
#define ll long long | |
const ll mod=1000000007; | |
ll facctoria(ll k){ | |
ll mol=1; | |
for (ll i=1;i<=k;++i) | |
{ | |
mol*=i; | |
mol%=mod; | |
} | |
return mol; | |
} | |
int main(){ | |
ll n,m;cin>>n>>m; | |
ll N=facctoria(n)%mod; | |
ll M=facctoria(m)%mod; | |
if(abs(n-m)==0){ | |
cout<<(2*N*M)%mod<<endl; | |
}else if(abs(n-m)==1){ | |
cout<<(N*M)%mod<<endl; | |
}else{ | |
cout<<0<<endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment