Submission #11643700


Source Code Expand

// Date: 2020-04-07

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

LL fac[N];
int main() {
    FIO;
    fac[0] = 1;
    rep(i, 1, N-1) fac[i] = fac[i-1] * i % mod;
    int n, m;
    cin >> n >> m;
    if(n > m) swap(n, m);
    LL ans = 0;
    if(n == m-1) {
        ans += fac[m] * fac[n] % mod;
    } else if(n == m) {
        ans += 2*fac[m]*fac[n]%mod;
    }
    cout << ans;

    return 0;
}

Submission Info

Submission Time
Task C - Reconciled?
User Gladinum
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1377 Byte
Status AC
Exec Time 3 ms
Memory 1792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 16
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt AC 3 ms 1792 KB
02.txt AC 3 ms 1792 KB
03.txt AC 3 ms 1792 KB
04.txt AC 3 ms 1792 KB
05.txt AC 3 ms 1792 KB
06.txt AC 3 ms 1792 KB
07.txt AC 3 ms 1792 KB
08.txt AC 3 ms 1792 KB
09.txt AC 3 ms 1792 KB
10.txt AC 3 ms 1792 KB
11.txt AC 3 ms 1792 KB
12.txt AC 3 ms 1792 KB
s1.txt AC 3 ms 1792 KB
s2.txt AC 3 ms 1792 KB
s3.txt AC 3 ms 1792 KB
s4.txt AC 3 ms 1792 KB