QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#318689#4798. Floor Tiles in a Parkjames1BadCreeperWA 1ms3684kbC++141.7kb2024-01-31 17:04:282024-01-31 17:04:28

Judging History

你现在查看的是最新测评结果

  • [2024-01-31 17:04:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3684kb
  • [2024-01-31 17:04:28]
  • 提交

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) {
    if (n < m) return 0; 
    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 * 11) % P; 
        ans = (ans + 1ll * (h - 1) * C(w - 1, 2) % P * 11) % P; 
        ans = (ans + 1ll * (w - 1) * (h - 1)) % P; 
        cout << ans << '\n'; 
        return 0; 
    }
    int ans = (C(w - 1, 4) + C(h - 1, 4)) % P; 
    ans = (ans + 7ll * (h - 1) % P * C(w - 1, 2)) % P; 
    ans = (ans + 7ll * (w - 1) % P * C(h - 1, 2)) % P; 
    ans = (ans + 26ll * (h - 1) % P * C(w - 1, 3)) % P; 
    ans = (ans + 26ll * (w - 1) % P * C(h - 1, 3)) % P; 
    ans = (ans + 64ll * C(w - 1, 2) % P * C(h - 1, 2)) % P; 
    cout << ans << '\n'; 
    return 0; 
}

/*
C(6,2) 
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3608kb

input:

2 3 5

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

4 3 5

output:

307

result:

ok 1 number(s): "307"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3492kb

input:

6 372065168 5

output:

114514

result:

ok 1 number(s): "114514"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

6 7 3

output:

145

result:

ok 1 number(s): "145"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

4 8 2

output:

10

result:

ok 1 number(s): "10"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

7 5 4

output:

1104

result:

ok 1 number(s): "1104"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

8 6 1

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

8 2 5

output:

1092

result:

ok 1 number(s): "1092"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

2 7 4

output:

191

result:

ok 1 number(s): "191"

Test #10:

score: 0
Accepted
time: 1ms
memory: 3496kb

input:

6 6 4

output:

1145

result:

ok 1 number(s): "1145"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

1 5 5

output:

1

result:

ok 1 number(s): "1"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

5 1 5

output:

1

result:

ok 1 number(s): "1"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

1 4 4

output:

1

result:

ok 1 number(s): "1"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

2 2 4

output:

1

result:

ok 1 number(s): "1"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

4 1 4

output:

1

result:

ok 1 number(s): "1"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

1 3 3

output:

1

result:

ok 1 number(s): "1"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

2 2 3

output:

4

result:

ok 1 number(s): "4"

Test #18:

score: 0
Accepted
time: 1ms
memory: 3680kb

input:

3 1 3

output:

1

result:

ok 1 number(s): "1"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1 2 2

output:

1

result:

ok 1 number(s): "1"

Test #20:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

2 1 2

output:

1

result:

ok 1 number(s): "1"

Test #21:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

2 2 2

output:

2

result:

ok 1 number(s): "2"

Test #22:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

1 2 1

output:

1

result:

ok 1 number(s): "1"

Test #24:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

2 1 1

output:

1

result:

ok 1 number(s): "1"

Test #25:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

1000000000 1000000000 5

output:

709563207

result:

ok 1 number(s): "709563207"

Test #26:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

1000000000 1000000000 4

output:

966434087

result:

ok 1 number(s): "966434087"

Test #27:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

1000000000 1000000000 3

output:

566309320

result:

ok 1 number(s): "566309320"

Test #28:

score: -100
Wrong Answer
time: 0ms
memory: 3676kb

input:

1000000000 1000000000 2

output:

1999999998

result:

wrong answer 1st numbers differ - expected: '3511292', found: '1999999998'