QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#317904 | #4798. Floor Tiles in a Park | james1BadCreeper | WA | 0ms | 3648kb | C++14 | 1.3kb | 2024-01-29 21:54:20 | 2024-01-29 21:54:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int P = 998244353;
inline int poww(int a, int b) {
int r = 1;
for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) r = 1ll * r * a % P;
return r;
}
int w, h, k;
inline int C(int n, int m) {
int ans = 1, ians = 1;
for (int i = n; i >= n - m + 1; --i) ans = 1ll * ans * i % P;
for (int i = 1; i <= m; ++i) ians = 1ll * ians * i % P;
return 1ll * ans * poww(ians, P - 2) % P;
}
int main(void) {
cin >> w >> h >> k;
if (k == 1) return cout << "1\n", 0;
if (k == 2) return cout << w + h - 2 << '\n', 0;
if (k == 3) {
int ans = (C(w - 1, 2) + C(h - 1, 2)) % P;
ans = (ans + 4ll * (w - 1) * (h - 1) % P) % P;
cout << ans << '\n';
return 0;
}
if (k == 4) {
int ans = (C(w - 1, 3) + C(h - 1, 3)) % P;
// (3 1) (1 3) (2 2) (2 2) 一条横线穿过去
// 一条横线穿一个 3
// 一条横线穿两个 4
ans = (ans + 1ll * (w - 1) * C(h - 1, 2) % P * 7) % P;
ans = (ans + 1ll * (h - 1) * C(w - 1, 2) % P * 7) % P;
ans = (ans + 1ll * (w - 1) * (h - 1)) % P;
cout << ans << '\n';
return 0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3648kb
input:
2 3 5
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements