Submission #5641879
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
int n, m, k;
const int mod = 1e9 + 7;
long long res2() {
long long num = m - 1;
long long res_x = 0, res_y = 0;
res_x = (long long)((num + 1) * (2 * num + 4) * num / 12) % mod;
res_x = res_x * n * n % mod;
num = n - 1;
res_y = (long long)((num + 1) * (2 * num + 4) * num / 12) % mod;
res_y = res_y * m * m % mod;
return (res_x + res_y) % mod;
}
long long comb(int a, int b) {
long long res = 1;
long long top = 1, bot = 1;
for (int i = 0; i < b; ++i) {
top = top * (a - i) % mod;
bot = bot * (b - i) % mod;
}
long long binpow = mod - 2, botinv = 1;
while (binpow) {
if (binpow & 1)
botinv = botinv * bot % mod;
bot = bot * bot % mod;
binpow >>= 1;
}
return (top * botinv) % mod;
}
int main() {
cin >> n >> m >> k;
long long res_2 = res2();
cout << res_2 * comb(n * m - 2, k - 2) % mod << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Cell Distance |
| User | bcoskun |
| Language | C++14 (GCC 5.4.1) |
| Score | 500 |
| Code Size | 1051 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 256 KiB |
Judge Result
| Set Name | Sample | All | ||
|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||
| Status | AC |
|
| Set Name | Test Cases |
|---|---|
| Sample | |
| 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, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt, s3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 1 ms | 256 KiB |
| 02.txt | AC | 1 ms | 256 KiB |
| 03.txt | AC | 1 ms | 256 KiB |
| 04.txt | AC | 1 ms | 256 KiB |
| 05.txt | AC | 1 ms | 256 KiB |
| 06.txt | AC | 1 ms | 256 KiB |
| 07.txt | AC | 1 ms | 256 KiB |
| 08.txt | AC | 2 ms | 256 KiB |
| 09.txt | AC | 1 ms | 256 KiB |
| 10.txt | AC | 2 ms | 256 KiB |
| 11.txt | AC | 1 ms | 256 KiB |
| 12.txt | AC | 1 ms | 256 KiB |
| 13.txt | AC | 2 ms | 256 KiB |
| 14.txt | AC | 1 ms | 256 KiB |
| 15.txt | AC | 1 ms | 256 KiB |
| 16.txt | AC | 2 ms | 256 KiB |
| 17.txt | AC | 2 ms | 256 KiB |
| 18.txt | AC | 2 ms | 256 KiB |
| 19.txt | AC | 1 ms | 256 KiB |
| 20.txt | AC | 1 ms | 256 KiB |
| 21.txt | AC | 2 ms | 256 KiB |
| 22.txt | AC | 2 ms | 256 KiB |
| s1.txt | AC | 1 ms | 256 KiB |
| s2.txt | AC | 1 ms | 256 KiB |
| s3.txt | AC | 1 ms | 256 KiB |