Submission #2549849
Source Code Expand
#if !defined(__clang__) && defined(__GNUC__) #include <bits/stdc++.h> #else #include <cstdlib> #include <climits> #include <iostream> #include <cstdint> #include <vector> #include <string> #include <complex> #include <bitset> #include <queue> #include <deque> #include <stack> #include <utility> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <regex> #endif // !defined(__clang__) && defined(__GNUG__) #include <boost/lexical_cast.hpp> #include <boost/algorithm/string.hpp> #include <boost/multi_array.hpp> #include <boost/optional.hpp> #include <boost/math/common_factor_rt.hpp> using namespace std; template<typename T> T absi(T x) { if (x < static_cast<T>(0)) { x *= static_cast<T>(-1); } return x; } template<typename T> T factorial(T n, T mod) { T ret = static_cast<T>(1); for (T i = 1; i <= n; ++i) { ret *= i; ret %= mod; } return ret; } int main() { int64_t N, M; std::cin >> N >> M; constexpr int64_t DIV = 1000000007; if (absi(N - M) > 1) { std::cout << 0 << std::endl; return 0; } if (N > M) { auto m = factorial(M, DIV); auto n = m * N; n %= DIV; n *= m; n %= DIV; std::cout << n << std::endl; } else if (N == M) { auto m = factorial(M, DIV); m *= m; m %= DIV; m *= 2; m %= DIV; std::cout << m << std::endl; } else { // N < M auto n = factorial(N, DIV); auto m = n * M; m %= DIV; m *= n; m %= DIV; std::cout << m << std::endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Reconciled? |
User | sumomoneko |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1673 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 1 ms | 256 KB |
02.txt | AC | 2 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 2 ms | 256 KB |
05.txt | AC | 2 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 2 ms | 256 KB |
10.txt | AC | 2 ms | 256 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |
s4.txt | AC | 2 ms | 256 KB |