Problem:
ビンゴ
問題
あるプログラミングコンテストでは,競技後の懇親会でビンゴゲームをする習わしがある．しかし,このビンゴゲームで使うビンゴカードは少々特殊で,以下の条件に従って作成される．
ビンゴカードは N 行 N 列のマス目に区切られており，各マス目には正整数が１つずつ書かれている．それらの整数は全て異なる．
マス目に書かれている整数は 1 以上 M 以下である．
ビンゴカードに書かれているN×N個の整数の合計は S である．
どの列を見たときも，上から下に向かって整数は昇順に並んでいる．
どのマス目の整数も，そのマス目より左の列のどの整数よりも大きい．
以下は， N = 5, M = 50, S = 685 のときのビンゴカードの例である．
懇親会のために上の条件を満たすビンゴカードをできるだけたくさん作りたい．ただし，同一のカードを2枚以上作ってはならない．作ることができるビンゴカードの枚数の最大値を 100000 で割った余りを出力するプログラムを作成せよ．
入力
入力は複数のデータセットからなる．各データセットは以下の形式で与えられる．
入力は1行からなり, その行にはビンゴカードのサイズ N (1≤N≤7), マス目に書かれている整数の上限 M (1≤M≤2000),ビンゴカードに書かれている整数の合計 S (1≤S≤3000) を表す3つの正整数が空白区切りで書かれている．ただし, 与えられるどの入力データにおいても，条件を満たすビンゴカードを1枚以上作ることができる．
N, M, S が 0 のとき入力の終了を示す. データセットの数は 5 を超えない．
出力
データセットごとに, 作ることができるビンゴカードの枚数の最大値を 100000 で割った余りを1行に出力せよ．
入出力例
入力例
3 9 45
3 100 50
5 50 685
0 0 0
出力例
1
7
74501
3つ目の入力例に対して，作ることができるビンゴカードの枚数の最大値は 642499974501 であるので， 100000 で割った余りの 74501 を出力する．
上記問題文と自動審判に使われるデータは、
情報オリンピック日本委員会
が作成し公開している問題文と採点用テストデータです。

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=100000;
int main(){
    ll N,M,S;
    while(cin>>N>>M>>S,N+M+S!=0){    vector<vector<ll>> DP(N*N+1,vector<ll>(S+1,0));
    DP[0][0]=1;
    for(int m=1;m<=M;m++){
        auto NDP=DP;
        for(int n=0;n<=N*N;n++){
            for(int s=0;s<=S;s++){
                if(n+1<=N*N&&m+s<=S){
                    NDP[n+1][m+s]+=DP[n][s];
                    NDP[n+1][m+s]%=mod;
                }
            }
        }
        swap(DP,NDP);
    }
    cout<<DP[N*N][S]<<endl;}
    
}
accuracy: 1
time_ms: 800
memory_kb: 5252
final_rank: 19

code_snippet: #include <iostream>
#include <cstring>
#include <omp.h>

using ll = long long;
const int inf = 1 << 29;
int dp[55][3030];

template <class T1, class T2>
inline bool minimize(T1& a, T2 b) {
    return b < a && (a = b, true);
}

template <class T1, class T2>
inline bool maximize(T1& a, T2 b) {
    return a < b && (a = b, true);
}

int main() {
    const int MOD = 100000;
    int N, M, S;
    while (std::cin >> N >> M >> S && (N | M | S)) {
        std::memset(dp, 0, sizeof(dp));  // Faster array initialization
        dp[0][0] = 1;
        // Parallelize outer two loops
        #pragma omp parallel for collapse(2)
        for (int add = 1; add <= M; ++add) {
            for (int currIndex = N * N; currIndex >= 1; --currIndex) {
                for (int currSum = add; currSum <= S; ++currSum) {
                    dp[currIndex][currSum] = (dp[currIndex][currSum] + dp[currIndex - 1][currSum - add]) % MOD;
                }
            }
        }
        std::cout << dp[N * N][S] << std::endl;
    }
    return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3988
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a)                                                               \
  { cout << #a << " = " << a << endl; }
template <class T1, class T2> inline bool minimize(T1 &a, T2 b) {
  return b < a && (a = b, 1);
}
template <class T1, class T2> inline bool maximize(T1 &a, T2 b) {
  return a < b && (a = b, 1);
}
typedef long long ll;
int const inf = 1 << 29;
int dp[55][3030];
int main() {
  int const MOD = 100000;
  for (int N, M, S; cin >> N >> M >> S && (N | M | S);) {
    rep(i, 55) rep(j, 3030) dp[i][j] = 0;
    dp[0][0] = 1;
    REP(add, 1, M + 1) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }
    cout << dp[N * N][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3960
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a)                                                               \
  { cout << #a << " = " << a << endl; }
template <class T1, class T2> inline bool minimize(T1 &a, T2 b) {
  return b < a && (a = b, 1);
}
template <class T1, class T2> inline bool maximize(T1 &a, T2 b) {
  return a < b && (a = b, 1);
}
typedef long long ll;
const int inf = 1 << 29;
int dp[55][3030];
int main() {
  const int MOD = 100000;
  for (int N, M, S; cin >> N >> M >> S && (N | M | S);) {
    rep(i, 55) rep(j, 3030) dp[i][j] = 0;
    dp[0][0] = 1;
    REP(add, 1, M + 1) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          if(currSum - add >= 0) { // Avoid undefined behaviour
            (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
          }
        }
      }
    }
    cout << dp[N * N][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 210
memory_kb: 3960
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template <class T1, class T2> inline bool minimize(T1 &a, T2 b) {
  return b < a && (a = b, 1);
}
template <class T1, class T2> inline bool maximize(T1 &a, T2 b) {
  return a < b && (a = b, 1);
}
typedef long long ll;
int const inf = 1 << 29;
int dp[55][3030];
int main() {
  int const MOD = 100000;
  for (int N, M, S; cin >> N >> M >> S && (N | M | S);) {
    int NN = N * N;
    rep(i, 55) rep(j, 3030) dp[i][j] = 0;
    dp[0][0] = 1;
    REP(add, 1, M + 1) {
      for (int currIndex = NN; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }
    cout << dp[NN][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 4072
final_rank: 12

code_snippet: #include <iostream>
#include <vector>

const int MODULO = 100000;

int main() {
  int numCount, numRange, targetSum;
  while (std::cin >> numCount >> numRange >> targetSum && (numCount || numRange || targetSum)) {
    std::vector<std::vector<int>> ways(numCount * numCount + 1, std::vector<int>(targetSum + 1, 0));
    ways[0][0] = 1;

    for (int add = 1; add <= numRange; ++add) {
      for (int currIndex = numCount * numCount; currIndex >= 1; --currIndex) {
        for (int currSum = add; currSum <= targetSum; ++currSum) {
          (ways[currIndex][currSum] += ways[currIndex - 1][currSum - add]) %= MODULO;
        }
      }
    }

    std::cout << ways[numCount * numCount][targetSum] << std::endl;
  }
  return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 3300
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a)                                                               \
  { cout << #a << " = " << a << endl; }
template <class T1, class T2> inline bool minimize(T1 &a, T2 b) {
  return b < a && (a = b, 1);
}
template <class T1, class T2> inline bool maximize(T1 &a, T2 b) {
  return a < b && (a = b, 1);
}
typedef long long ll;
int const inf = 1 << 29;
int dp[55][3030];
int main() {
  int const MOD = 100000;
  for (int N, M, S; cin >> N >> M >> S && (N | M | S);) {
    // Initialize only necessary part of dp array
    REP(i, 0, N * N + 1) {
      REP(j, 0, S + 1) {
        dp[i][j] = 0;
      }
    }
    dp[0][0] = 1;
    REP(add, 1, M + 1) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }
    cout << dp[N * N][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3784
final_rank: 3

code_snippet: #include <iostream>
#include <cstring>
using namespace std;

typedef long long ll;

int const MOD = 100000;

int main() {
    int const MAX_N = 55;
    int const MAX_S = 3030;
    int dp[MAX_N * MAX_N + 1][MAX_S + 1];

    int N, M, S;
    while (cin >> N >> M >> S && (N | M | S)) {
        // Clear dp array
        memset(dp, 0, sizeof dp);

        dp[0][0] = 1;

        for (int add = 1; add <= M; add++) {
            for (int currIndex = N * N; currIndex >= 1; currIndex--) {
                for (int currSum = add; currSum <= S; currSum++) {
                    int prevSum = currSum - add;
                    dp[currIndex][currSum] = (dp[currIndex][currSum] + dp[currIndex - 1][prevSum]) % MOD;
                }
            }
        }

        cout << dp[N * N][S] << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 38880
final_rank: 20

code_snippet: #include <iostream>
#include <vector>

template <class T1, class T2> 
inline bool minimize(T1 &a, T2 b) {
  return b < a && (a = b, 1);
}

template <class T1, class T2> 
inline bool maximize(T1 &a, T2 b) {
  return a < b && (a = b, 1);
}

typedef long long ll;

constexpr int inf = 1 << 29;
int dp[55][3030];

int main() {
  constexpr int MOD = 100000;
  int N, M, S;
  while(std::cin >> N >> M >> S && (N | M | S)){
    for(int i=0; i<55; i++)
      for(int j=0; j<3030; j++)
        dp[i][j] = 0;
        
    dp[0][0] = 1;
    
    for(int add=1; add <= M; add++) {
      for(int currIndex=N*N; currIndex >=1; currIndex--){
        for(int currSum=add; currSum <= S; currSum++){
          dp[currIndex][currSum] = (dp[currIndex][currSum] + dp[currIndex - 1][currSum - add]) % MOD;
        }
      }
    }
    std::cout << dp[N*N][S] << std::endl;
  }
  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3976
final_rank: 8

code_snippet: #include <iostream>
#include <vector>
using namespace std;
const int inf = 1 << 29;
int main() {
  int const MOD = 100000;
  vector<vector<int>> dp(55, vector<int>(3030, 0));
  for (int N, M, S; cin >> N >> M >> S && (N | M | S);) {
    for(auto& v: dp)
        fill(v.begin(), v.end(), 0);
    dp[0][0] = 1;
    int maxIndex = N * N;
    for (int add = 1; add <= M; ++add) {
      for (int currIndex = maxIndex; currIndex >= 1; --currIndex) {
        for (int currSum = add; currSum <= S; ++currSum) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }
    cout << dp[maxIndex][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3636
final_rank: 2

code_snippet: #include <iostream>
#include <cstring>

#define REP(i, a, b) for (int i = a; i < (int)b; i++)

typedef int int32;
int32 const inf = 1 << 29;
int32 dp[55][3030];

int main() {
  int32 const MOD = 100000;
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);

  for (int32 N, M, S; std::cin >> N >> M >> S && (N || M || S);) {
    std::memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    REP(add, 1, M + 1) {
      for (int32 currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int32 currSum = add; currSum <= S; currSum++) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }
    std::cout << dp[N * N][S] << std::endl;
  }
  return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 3996
final_rank: 16

code_snippet: #include<iostream>
#include <vector>
using namespace std;

typedef long long ll;
const int MOD = 100000;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  vector<vector<int>> dp(55,vector<int>(3030,0));

  int N, M, S;

  while (cin >> N >> M >> S && (N | M | S)) {
    for(int i = 0; i<55; i++)
      for(int j = 0; j<3030; j++)
        dp[i][j] = 0;

    dp[0][0] = 1;

    for (int add = 1; add <= M; add++) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }
    cout << dp[N * N][S] << "\n";
  }
  return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 3716
final_rank: 14

code_snippet: #include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;
const int inf = 1 << 29;
int dp[55][3030];

bool minimize(int &a, int b) {
  return b < a && (a = b, 1);
}

bool maximize(int &a, int b) {
  return a < b && (a = b, 1);
}

int main() {
  std::ios_base::sync_with_stdio(false); cin.tie(NULL);

  const int MOD = 100000;
  for (int N, M, S; cin >> N >> M >> S && (N | M | S);) {
    for(int i=0; i<55; i++) {
      for(int j=0; j<3030; j++) {
        dp[i][j] = 0;
      }
    }
    dp[0][0] = 1;
    for(int add = 1; add < M + 1; add++) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }
    cout << dp[N * N][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 190
memory_kb: 3976
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int const inf = 1 << 29;
int dp[55][3030];
int main() {
  int const MOD = 100000;
  int N, M, S;
  while (scanf("%d %d %d", &N, &M, &S) && (N | M | S)) {
    fill(&dp[0][0], &dp[0][0] + sizeof(dp) / sizeof(int), 0);
    dp[0][0] = 1;
    for (int add = 1; add <= M; add++) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          dp[currIndex][currSum] += dp[currIndex - 1][currSum - add];
          if (dp[currIndex][currSum] >= MOD) dp[currIndex][currSum] -= MOD;
        }
      }
    }
    printf("%d\n", dp[N * N][S]);
  }
  return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 4168
final_rank: 1

code_snippet: #include <iostream>

const int MOD = 100000;
const int MAX_INDEX = 55;
const int MAX_SUM = 3030;

int dp[MAX_INDEX][MAX_SUM];

int main() {
    for (int N, M, S; std::cin >> N >> M >> S && (N | M | S);) {
        for(int i = 0; i < MAX_INDEX; ++i) {
            for(int j = 0; j < MAX_SUM; ++j) {
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;
        for (int add = 1; add <= M; ++add) {
            for (int currIndex = N * N; currIndex >= 1; --currIndex) {
                for (int currSum = add; currSum <= S; ++currSum) {
                    (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
                }
            }
        }
        std::cout << dp[N * N][S] << std::endl;
    }
    return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 3816
final_rank: 15

code_snippet: #include <iostream>
#include <vector>
#include <cstdint>
using namespace std;

int main() {
  const int MOD = 100000;
  vector<vector<int64_t>> dp(55, vector<int64_t>(3030, 0));

  for (int N, M, S; cin >> N >> M >> S && (N | M | S);) {
    for(auto &v : dp) 
      fill(v.begin(), v.end(), 0);
    dp[0][0] = 1;
    int total = N * N;
    for (int add = 1; add <= M; ++add) {
      for (int currIndex = total; currIndex >= 1; --currIndex) {
        for (int currSum = add; currSum <= S; ++currSum) {
          (dp[currIndex][currSum] += dp[currIndex - 1][currSum - add]) %= MOD;
        }
      }
    }
    cout << dp[total][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 4012
final_rank: 11

code_snippet: #include <iostream>
#include <vector>

typedef long long ll;

int main() {
  int const MOD = 100000;
  for (int N, M, S; std::cin >> N >> M >> S && (N | M | S);) {
    std::vector<std::vector<int>> dp(N * N + 1, std::vector<int>(S + 1));
    dp[0][0] = 1;
    for (int add = 1; add <= M; add++) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          dp[currIndex][currSum] += dp[currIndex - 1][currSum - add];
          dp[currIndex][currSum] %= MOD;
        }
      }
    }
    std::cout << dp[N * N][S] << std::endl;
  }
  return 0;
}
accuracy: 1
time_ms: 180
memory_kb: 3564
final_rank: 13

code_snippet: #include <iostream>
using namespace std;

const int MOD = 100000;
const int MAX_N = 55;
const int MAX_S = 3030;

int dp[MAX_N][MAX_S];

int main() {
  int N, M, S;
  while (cin >> N >> M >> S && (N | M | S)) {
    for (int i = 0; i <= N * N; i++) {
      for (int j = 0; j <= S; j++) {
        dp[i][j] = 0;
      }
    }
    dp[0][0] = 1;
    for (int add = 1; add <= M; add++) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          dp[currIndex][currSum] += dp[currIndex - 1][currSum - add];
          dp[currIndex][currSum] %= MOD;
        }
      }
    }
    cout << dp[N * N][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3908
final_rank: 6

code_snippet: #include <iostream>
using namespace std;

typedef long long ll;

int const inf = 1 << 29;

int dp[55][3030];

int main() {
  int const MOD = 100000;
  int N, M, S;
  while (cin >> N >> M >> S && (N != 0 && M != 0 && S != 0)) {
    for (int i = 0; i < 55; i++) {
      for (int j = 0; j < 3030; j++) {
        dp[i][j] = 0;
      }
    }
    dp[0][0] = 1;
    for (int add = 1; add <= M; add++) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = add; currSum <= S; currSum++) {
          int temp = dp[currIndex - 1][currSum - add];
          dp[currIndex][currSum] = (dp[currIndex][currSum] + temp) % MOD;
        }
      }
    }
    cout << dp[N * N][S] << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3816
final_rank: 5

code_snippet: #include <iostream>
using namespace std;

typedef long long ll;

const int MOD = 100000;

int dp[55][3030];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  while (true) {
    int N, M, S;
    cin >> N >> M >> S;
    
    if (N == 0 && M == 0 && S == 0) {
      break;
    }

    for (int i = 0; i < 55; i++) {
      for (int j = 0; j < 3030; j++) {
        dp[i][j] = 0;
      }
    }
    
    dp[0][0] = 1;

    for (int add = 1; add <= M; add++) {
      for (int currIndex = N * N; currIndex >= 1; currIndex--) {
        for (int currSum = S; currSum >= add; currSum--) {
          dp[currIndex][currSum] = (dp[currIndex][currSum] + dp[currIndex - 1][currSum - add]) % MOD;
        }
      }
    }

    cout << dp[N * N][S] << endl;
  }

  return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 4008
final_rank: 10