QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#180607#4296. Multiple Subject LessonsSorahISAAC ✓2ms3560kbC++202.3kb2023-09-16 01:26:082023-09-16 01:26:08

Judging History

This is the latest submission verdict.

  • [2023-09-16 01:26:08]
  • Judged
  • Verdict: AC
  • Time: 2ms
  • Memory: 3560kb
  • [2023-09-16 01:26:08]
  • Submitted

answer

#ifndef Yamada
#define Yamada
#include Yamada __FILE__ Yamada

const int maxn = 30;

vector cnm(maxn, vector<int>(maxn));

void recur(int &ans, const int &K, int sum, int lst, int way) {
    if (lst >= 3) {
        for (int i = 2; i < lst; ++i) {
            for (int j = 1; j <= sum/i; ++j) {
                recur(ans, K, sum - i*j, i, way * cnm[j+K-1][j]);
            }
        }
    }
    ans += way * cnm[sum+K-1][sum];
}

void solve() {
    int N, K; cin >> N >> K;
    
    int ans = 0;
    recur(ans, K, N, N+1, 1);
    cout << ans << "\n";
}

void init() {
    for (int i = 0; i < maxn; ++i) cnm[i][0] = cnm[i][i] = 1;
    for (int i = 2; i < maxn; ++i) {
        for (int j = 1; j < i; ++j) cnm[i][j] = cnm[i-1][j-1] + cnm[i-1][j];
    }
}

signed main() {
    IOS();
    init();
    int t = 1; // cin >> t;
    for (int i = 1; i <= t; ++i) solve();
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
// #define double __float80
using pii = pair<int, int>;
template <typename T> using MaxHeap = std::priority_queue<T>;
template <typename T> using MinHeap = std::priority_queue<T, vector<T>, greater<T>>;

// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define SZ(a) (int)((a).size())
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)

#ifdef local
#define IOS() void()
#define debug(...) \
    fprintf(stderr, "%sAt [%s], line %d: (%s) = ", "\u001b[33m", __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), fprintf(stderr, "%s", "\u001b[0m")
template <typename T> void _do(T &&_t) {cerr << _t << "\n";}
template <typename T, typename ...U> void _do(T &&_t, U &&..._u) {cerr << _t << ", ", _do(_u...);}
#else
#define IOS() ios_base::sync_with_stdio(0); cin.tie(0)
#define debug(...) void()
#define endl '\n'
#endif

// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename T, typename U> bool chmin(T &lhs, U rhs) {return lhs > rhs ? lhs = rhs, 1 : 0;}
template <typename T, typename U> bool chmax(T &lhs, U rhs) {return lhs < rhs ? lhs = rhs, 1 : 0;}

#endif

詳細信息

Test #1:

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

input:

3 2

output:

10

result:

ok answer is '10'

Test #2:

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

input:

1 1

output:

1

result:

ok answer is '1'

Test #3:

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

input:

1 2

output:

2

result:

ok answer is '2'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3468kb

input:

1 3

output:

3

result:

ok answer is '3'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3468kb

input:

1 15

output:

15

result:

ok answer is '15'

Test #6:

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

input:

2 1

output:

2

result:

ok answer is '2'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

2 2

output:

5

result:

ok answer is '5'

Test #8:

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

input:

2 3

output:

9

result:

ok answer is '9'

Test #9:

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

input:

2 15

output:

135

result:

ok answer is '135'

Test #10:

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

input:

3 1

output:

3

result:

ok answer is '3'

Test #11:

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

input:

3 2

output:

10

result:

ok answer is '10'

Test #12:

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

input:

3 3

output:

22

result:

ok answer is '22'

Test #13:

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

input:

3 15

output:

920

result:

ok answer is '920'

Test #14:

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

input:

4 1

output:

5

result:

ok answer is '5'

Test #15:

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

input:

4 2

output:

20

result:

ok answer is '20'

Test #16:

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

input:

4 3

output:

51

result:

ok answer is '51'

Test #17:

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

input:

4 4

output:

105

result:

ok answer is '105'

Test #18:

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

input:

4 15

output:

5220

result:

ok answer is '5220'

Test #19:

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

input:

5 1

output:

7

result:

ok answer is '7'

Test #20:

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

input:

5 2

output:

36

result:

ok answer is '36'

Test #21:

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

input:

5 3

output:

108

result:

ok answer is '108'

Test #22:

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

input:

5 5

output:

506

result:

ok answer is '506'

Test #23:

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

input:

5 15

output:

25893

result:

ok answer is '25893'

Test #24:

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

input:

10 1

output:

42

result:

ok answer is '42'

Test #25:

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

input:

10 2

output:

481

result:

ok answer is '481'

Test #26:

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

input:

10 3

output:

2640

result:

ok answer is '2640'

Test #27:

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

input:

10 5

output:

31027

result:

ok answer is '31027'

Test #28:

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

input:

10 10

output:

1605340

result:

ok answer is '1605340'

Test #29:

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

input:

10 15

output:

22414314

result:

ok answer is '22414314'

Test #30:

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

input:

14 1

output:

135

result:

ok answer is '135'

Test #31:

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

input:

14 2

output:

2665

result:

ok answer is '2665'

Test #32:

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

input:

14 3

output:

21843

result:

ok answer is '21843'

Test #33:

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

input:

14 7

output:

4715510

result:

ok answer is '4715510'

Test #34:

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

input:

14 14

output:

1119974875

result:

ok answer is '1119974875'

Test #35:

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

input:

14 15

output:

2039031360

result:

ok answer is '2039031360'

Test #36:

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

input:

15 1

output:

176

result:

ok answer is '176'

Test #37:

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

input:

15 2

output:

3956

result:

ok answer is '3956'

Test #38:

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

input:

15 3

output:

35581

result:

ok answer is '35581'

Test #39:

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

input:

15 7

output:

9869132

result:

ok answer is '9869132'

Test #40:

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

input:

15 15

output:

5796944357

result:

ok answer is '5796944357'

Test #41:

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

input:

13 12

output:

114945780

result:

ok answer is '114945780'

Test #42:

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

input:

12 3

output:

7868

result:

ok answer is '7868'

Test #43:

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

input:

8 7

output:

32305

result:

ok answer is '32305'

Test #44:

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

input:

11 3

output:

4599

result:

ok answer is '4599'

Test #45:

score: 0
Accepted
time: 2ms
memory: 3436kb

input:

2 13

output:

104

result:

ok answer is '104'

Test #46:

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

input:

11 8

output:

1020416

result:

ok answer is '1020416'

Test #47:

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

input:

9 14

output:

4263770

result:

ok answer is '4263770'

Test #48:

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

input:

10 6

output:

81816

result:

ok answer is '81816'

Test #49:

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

input:

6 13

output:

60697

result:

ok answer is '60697'

Test #50:

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

input:

3 9

output:

255

result:

ok answer is '255'

Test #51:

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

input:

6 5

output:

1265

result:

ok answer is '1265'

Test #52:

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

input:

1 6

output:

6

result:

ok answer is '6'

Test #53:

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

input:

2 6

output:

27

result:

ok answer is '27'

Test #54:

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

input:

7 2

output:

110

result:

ok answer is '110'

Test #55:

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

input:

2 8

output:

44

result:

ok answer is '44'

Test #56:

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

input:

15 6

output:

3174210

result:

ok answer is '3174210'

Test #57:

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

input:

9 9

output:

315445

result:

ok answer is '315445'

Test #58:

score: 0
Accepted
time: 2ms
memory: 3516kb

input:

4 6

output:

315

result:

ok answer is '315'

Test #59:

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

input:

15 5

output:

885723

result:

ok answer is '885723'

Test #60:

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

input:

9 10

output:

573430

result:

ok answer is '573430'

Test #61:

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

input:

5 13

output:

14820

result:

ok answer is '14820'

Test #62:

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

input:

12 15

output:

229972855

result:

ok answer is '229972855'

Test #63:

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

input:

12 4

output:

35693

result:

ok answer is '35693'

Test #64:

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

input:

3 10

output:

330

result:

ok answer is '330'

Test #65:

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

input:

12 7

output:

1006145

result:

ok answer is '1006145'

Test #66:

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

input:

13 3

output:

13209

result:

ok answer is '13209'

Test #67:

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

input:

10 4

output:

10108

result:

ok answer is '10108'

Test #68:

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

input:

7 14

output:

333608

result:

ok answer is '333608'

Test #69:

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

input:

9 1

output:

30

result:

ok answer is '30'

Test #70:

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

input:

8 3

output:

810

result:

ok answer is '810'

Test #71:

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

input:

10 14

output:

14071827

result:

ok answer is '14071827'

Test #72:

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

input:

7 11

output:

100529

result:

ok answer is '100529'

Test #73:

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

input:

15 9

output:

70066809

result:

ok answer is '70066809'

Test #74:

score: 0
Accepted
time: 2ms
memory: 3444kb

input:

1 13

output:

13

result:

ok answer is '13'

Test #75:

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

input:

10 13

output:

8600501

result:

ok answer is '8600501'

Test #76:

score: 0
Accepted
time: 2ms
memory: 3440kb

input:

11 13

output:

26173966

result:

ok answer is '26173966'

Test #77:

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

input:

7 5

output:

2990

result:

ok answer is '2990'

Test #78:

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

input:

5 10

output:

5512

result:

ok answer is '5512'

Test #79:

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

input:

4 11

output:

1925

result:

ok answer is '1925'

Test #80:

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

input:

3 13

output:

637

result:

ok answer is '637'