Search is not available for this dataset
name
stringlengths 2
88
| description
stringlengths 31
8.62k
| public_tests
dict | private_tests
dict | solution_type
stringclasses 2
values | programming_language
stringclasses 5
values | solution
stringlengths 1
983k
|
---|---|---|---|---|---|---|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int M = 100000;
int n, ub;
map<int, int> memo[50][2001];
int dfs(int idx, int lb, int sum) {
if (idx == n) return sum == 0;
if (sum < 0 || lb > ub) return 0;
if (memo[idx][lb].count(sum) > 0) return memo[idx][lb][sum];
int cnt = 0;
for (int i = lb; i <= ub; i++) {
cnt += dfs(idx + 1, i + 1, sum - i);
if (cnt >= M) cnt -= M;
}
return memo[idx][lb][sum] = cnt;
}
int main() {
for (int sum; scanf("%d%d%d", &n, &ub, &sum), n;) {
n *= n;
for (int i = 0; i < (n); i++)
for (int lb = 0; lb < (ub + 1); lb++) memo[i][lb].clear();
printf("%d\n", dfs(0, 1, sum));
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
const int mod = 100000;
int main() {
while (true) {
int n, m, s; cin >> n >> m >> s;
if (n == 0 and m == 0 and s == 0) break;
vector<vector<int> > dp(vector<vector<int> >(s+1, vector<int>(m+1)));
dp[0][0] = 1;
repeat (i,n*n) {
vector<vector<int> > acc(vector<vector<int> >(s+1, vector<int>(m+1)));
repeat (j,s+1) {
repeat (k,m) {
acc[j][k+1] = (acc[j][k] +(ll) dp[j][k]) % mod;
}
}
repeat (j,s+1) {
repeat (k,min(m,j)+1) {
dp[j][k] = acc[j-k][k];
}
}
}
int ans = accumulate(dp[s].begin(), dp[s].end(), 0) % mod;
cout << ans << endl;
}
return 0;
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
vector<vector<Mod>> mp(M + 1, vector<Mod>(rest + 1));
mp[0][rest] = 1;
int amax = 0;
int amin = rest;
for (int i = 0; i < asize; ++i) {
vector<vector<Mod>> nextmp(M + 1, vector<Mod>(rest + 1));
int aamax = amax;
int aamin = amin;
for (int j = 0; j <= amax; ++j) {
for (int k = amin; k < mp[j].size(); ++k) {
const int least = j;
const int arest = k;
for (int n = least; n <= min(M - asize, arest / (asize - i)); ++n) {
nextmp[n][arest - n] += mp[j][k];
}
aamax = max(aamax, (min(M - asize, arest / asize - i)));
aamin = min(aamin, arest - min(M - asize, arest / (asize - i)));
}
}
amin = min(aamin, amin);
amax = max(aamax, amax);
mp = nextmp;
}
Mod ans = 0;
for (int i = 0; i < mp.size(); ++i) ans += mp[i][0];
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int mod = 100000;
int dp[2][51][3001];
int main() {
while (true) {
int N, M, S;
scanf("%d%d%d", &N, &M, &S);
if (N == 0 && M == 0 && S == 0) break;
N *= N;
memset(dp, 0, sizeof(dp));
int t = 0;
dp[1 - t][0][0] = 1;
for (int i = 0; i < M; i++) {
for (int j = 0; j <= N; j++)
for (int k = 0; k <= S; k++) dp[t][j][k] = 0;
for (int j = 0; j <= N; j++)
for (int k = 0; j + k <= S; k++) {
if (k + j <= S) {
dp[t][j][j + k] += dp[1 - t][j][k];
if (dp[t][j][j + k] >= mod) dp[t][j][j + k] -= mod;
}
if (k + j + 1 <= S) {
dp[t][j + 1][j + k + 1] += dp[1 - t][j][k];
if (dp[t][j + 1][j + k + 1] >= mod) dp[t][j + 1][j + k + 1] -= mod;
}
}
t = 1 - t;
}
printf("%d\n", dp[1 - t][N][S]);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int i, j, k;
int n, m, s;
for (i = 0; scanf("%d%d%d", &n, &m, &s), n; ++i) {
if (i == 1) {
if (n == 2)
for (;;)
;
else if (n == 4)
exit(1);
}
}
puts("a");
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <typename T>
vector<T> make_v(size_t a) {
return vector<T>(a);
}
template <typename T>
vector<vector<T> > make_v(size_t a, size_t b) {
return vector<vector<T> >(a, make_v<T>(b));
}
template <typename T>
vector<vector<vector<T> > > make_v(size_t a, size_t b, size_t c) {
return vector<vector<vector<T> > >(a, make_v<T>(b, c));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t) fill_v(e, v);
}
signed main() {
Int n, m, s;
while (cin >> n >> m >> s, n) {
const Int MOD = 100000;
int v = n * n;
s -= v * (v + 1) / 2;
m -= v;
auto dp = make_v<signed>(v + 1, s + 1, m + 1);
fill_v(dp, 0);
dp[0][0][0] = 1;
for (int i = 0; i < v; i++) {
int c = v - i;
for (int j = 0; j <= s; j++) {
for (int k = 0; k <= m; k++) {
dp[i + 1][j][k] += dp[i][j][k];
dp[i + 1][j][k] %= MOD;
if (j + c <= s && k + 1 <= m) {
dp[i][j + c][k + 1] += dp[i][j][k];
dp[i][j + c][k + 1] %= MOD;
}
}
}
}
int ans = 0;
for (int i = 0; i <= m; i++) {
ans += dp[v][s][i];
ans %= MOD;
}
cout << ans << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int surplus = 100000;
int n, m, s, N, ans, ss[50];
int b[50][2001][3001];
bool judge[50][2001][3001];
int dp(int now, int num, int sum) {
ss[now] = 0;
for (int i = (num); i < (m + 1); i++) {
if (now == N) {
if (sum + i == s) {
return 1;
} else if (i == m) {
return 0;
}
} else {
if (!judge[now][i][sum]) {
b[now][i][sum] = dp(now + 1, i + 1, sum + i);
judge[now][i][sum] = 1;
b[now][i][sum] %= surplus;
}
ss[now] += b[now][i][sum];
}
}
return ss[now];
}
int main() {
while (cin >> n >> m >> s) {
if (!n && !m && !s) return 0;
ans = 0;
N = n * n;
dp(1, 1, 0);
for (int i = (1); i < (m + 1); i++) {
ans += b[1][i][0];
}
ans %= surplus;
cout << ans << endl;
for (int i = (1); i < (50); i++) {
ss[i] = 0;
for (int j = (1); j < (2001); j++) {
for (int k = (0); k < (3001); k++) {
b[i][j][k] = 0;
judge[i][j][k] = 0;
}
}
}
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int mod = 100000;
int N, M, S;
int main() {
while (cin >> N >> M >> S, N) {
N *= N;
M -= N;
S -= N * (N + 1) / 2;
vector<vector<int> > dp(M + 1, vector<int>(S + 1, 0));
dp[0][0] = 1;
for (int i = 0; i < N; i++) {
vector<vector<int> > dp2(M + 1, vector<int>(S + 1, 0));
for (int j = 1; j <= M; j++) {
for (int k = j; k <= S; k++) {
dp2[j][k] = dp2[j][k - j];
if (j >= 1) {
dp2[j][k] += dp[j - 1][k - 1];
if (dp2[j][k] >= mod) dp2[j][k] -= mod;
}
}
}
dp = dp2;
}
int ret = 0;
for (int i = 0; i <= M; i++) {
ret += dp[i][S];
if (ret >= mod) ret -= mod;
}
cout << ret << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[50][2001][3001];
int main() {
int n, m, s;
while (scanf("%d%d%d", &n, &m, &s), (n | m | s)) {
for (int i = 0; i < n * n + 1; i++)
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[i][j][k] = 0;
for (int i = 1; i < m + 1; i++) {
for (int j = 1; j < i + 1; j++) {
dp[1][i][j] = 1;
}
}
m++;
s++;
for (int i = 2; i < n * n + 1; i++) {
for (int j = 1; j < m; j++) {
for (int k = 1; k < s; k++) {
dp[i][j][k] += dp[i][j - 1][k];
if (k >= j) {
dp[i][j][k] += dp[i - 1][j - 1][k - j];
dp[i][j][k] %= 100000;
}
dp[i][j][k] %= 100000;
}
}
}
printf("%d\n", dp[n * n][m - 1][s - 1] % 100000);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const int mod = 100000;
int n, m, s, dp[2][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s), n) {
for (int i = 0; i < m + 1; i++)
for (int j = 0; j < s + 1; j++) dp[0][i][j] = 0;
dp[0][0][s] = 1;
int cur = 0, next = 1;
for (int i = 0; i < n * n; i++) {
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[next][j][k] = 0;
for (int j = i; j <= m; j++)
for (int k = 0; k <= s; k++)
if (dp[j][k]) {
for (int l = j + 1; l <= m; l++)
if (k - l >= 0) {
dp[next][l][k - l] = (dp[next][l][k - l] + dp[cur][j][k]) % mod;
if (l * (n * n - i) > k) break;
}
}
swap(cur, next);
}
int ans = 0;
for (int i = 0; i < m + 1; i++) ans += dp[cur][i][0];
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
int DP[2001][3001];
int DP1[2001][3001];
const int MOD = 100000;
int main() {
scanf("%d%d%d", &N, &M, &S);
for (int j = 1; j <= min(M, S); j++) DP[j][j] = 1;
for (int i = 1; i < N * N; i++) {
for (int j = 1; j <= M; j++) {
for (int k = 1; k <= S; k++) DP1[j][k] = 0;
}
for (int j = 1; j <= M; j++) {
for (int k = 1; k <= S; k++) {
if (DP[j][k] == 0) continue;
for (int l = j + 1; (k + l <= S) && (l <= M); l++) {
DP1[l][k + l] += DP[j][k];
DP1[l][k + l] %= MOD;
}
}
}
for (int j = 1; j <= M; j++) {
for (int k = 1; k <= S; k++) {
DP[j][k] = DP1[j][k];
}
}
}
int ans = 0;
for (int j = 1; j <= M; j++) {
for (int k = S; k <= S; k++) {
ans += DP[j][k];
ans %= MOD;
}
}
printf("%d\n", ans);
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.*;
public class Main{
static final int m_max=2001, s_max=3001;
public static void main(String[] args){
Scanner scn = new Scanner(System.in);
int[][][] table = new int[2][m_max][s_max];
int n,m,s;
while(true){
n = scn.nextInt();
n = n*n;
m = scn.nextInt();
s = scn.nextInt();
if(n==0&&m==0&&s==0) break;
for(int i=1; i<=m; i++) for(int j=1; j<=n; j++)
table[0][i][j] = (i >= j)?1:0;
for(int i=1; i<n; i++) for(int j=1; j<=m; j++) for(int k=1; k<=s; k++)
if((j*2-i)*(i+1)/2 < k || j==1){
table[i&1][j][k] = 0;
}else if(k <= j){
table[i&1][j][k] = table[i&1][j-1][k];
}else{
table[i&1][j][k] = (table[i&1][j-1][k] + table[~i&1][j-1][k-j])%100000;
}
System.out.println(table[~n&1][m][s]);
}
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
vector<vector<Mod>> mp(M + 1, vector<Mod>(rest + 1));
mp[0][rest] = 1;
for (int i = 0; i < asize; ++i) {
vector<vector<Mod>> nextmp(M + 1, vector<Mod>(rest + 1));
for (int j = 0; j < mp.size(); ++j) {
for (int k = 0; k < mp[j].size(); ++k) {
int least = j;
int arest = k;
for (int n = least; n <= min(M - asize, arest / (asize - i)); ++n) {
nextmp[n][arest - n] += mp[j][k];
}
}
}
mp = nextmp;
}
Mod ans = 0;
for (int i = 0; i < mp.size(); ++i) ans += mp[i][0];
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using V = vector<T>;
template <class T, class U>
using P = pair<T, U>;
const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;
template <class T>
void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &obj) {
o << "{";
for (auto &x : obj)
o << " {" << x.first << " : " << x.second << "}"
<< ",";
o << " }";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &obj) {
o << "{";
for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i];
o << "}";
return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &obj) {
o << "{" << obj.first << ", " << obj.second << "}";
return o;
}
template <template <class tmp> class T, class U>
ostream &operator<<(ostream &o, const T<U> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
void print(void) { cout << endl; }
template <class Head>
void print(Head &&head) {
cout << head;
print();
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
cout << head << " ";
print(forward<Tail>(tail)...);
}
template <class T>
void chmax(T &a, const T b) {
a = max<T>(a, b);
}
template <class T>
void chmin(T &a, const T b) {
a = min<T>(a, b);
}
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
N = N * N;
V<V<int>> dp(2 * (N + 1), V<int>(S + 1, 0));
dp[0][0] = 1;
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N + 1; ++j) {
for (int k = 0; k < S + 1; ++k) {
if (j + 1 <= N && k + i + 1 <= S)
(dp[((i + 1) % 2) * (N + 1) + j + 1][k + (i + 1)] +=
dp[(i % 2) * (N + 1) + j][k]) %= 100000LL;
else
break;
}
for (int k = 0; k < S + 1; ++k) {
(dp[((i + 1) % 2) * (N + 1) + j][k] +=
dp[(i % 2) * (N + 1) + j][k]) %= 100000LL;
}
}
}
cout << dp[(M % 2) * (N + 1) + N][S] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static final int MAX_N = 7;
public static final int MAX_D = MAX_N * MAX_N;
public static final int MAX_M = 2000;
public static final int MAX_S = 3000;
public static ArrayList<ArrayList<HashMap<Integer, Integer>>> memo = new ArrayList<ArrayList<HashMap<Integer,Integer>>>(MAX_D);
public static int DFS(final int rest_D, final int upper_bound_M, final int rest_S){
//System.out.println(rest_D + " " + upper_bound_M + " " + rest_S);
final int minimal_S = (rest_D * (rest_D + 1)) / 2;
final int minimal_rest_S = minimal_S - rest_D;
final int new_bound_M = Math.min(upper_bound_M, rest_S - minimal_rest_S);
//System.out.println(rest_D + " " + new_bound_M + " " + rest_S);
if(memo.get(rest_D).get(new_bound_M).containsKey(rest_S)){
return memo.get(rest_D).get(new_bound_M).get(rest_S);
}else if(rest_D == 0){
final int ret = rest_S == 0 ? 1 : 0;
memo.get(rest_D).get(new_bound_M).put(rest_S, ret);
return ret;
}else if(minimal_S >= rest_S){
final int ret = minimal_S == rest_S ? 1 : 0;
memo.get(rest_D).get(new_bound_M).put(rest_S, ret);
return ret;
}
System.out.println("hi");
int sum = 0;
for(int cur_M = new_bound_M; cur_M >= rest_D; cur_M--){
final int need_S = minimal_rest_S + cur_M;
final int over_S = (cur_M * (cur_M + 1)) / 2 - ((cur_M - rest_D) * (cur_M - rest_D + 1)) / 2;
//System.out.println(cur_M + " " + need_S + " " + over_S + " : " + rest_S);
if(need_S > rest_S){
continue;
}else if(need_S == rest_S){
sum += 1;
sum %= 100000;
continue;
}else if(over_S == rest_S){
sum += 1;
sum %= 100000;
continue;
}else if(over_S < rest_S){
break;
}else{
sum += DFS(rest_D - 1, cur_M - 1, rest_S - cur_M);
sum %= 100000;
}
}
memo.get(rest_D).get(upper_bound_M).put(rest_S, sum);
return sum;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int d = 0; d <= MAX_D; d++){
ArrayList<HashMap<Integer, Integer>> adder = new ArrayList<HashMap<Integer,Integer>>();
for(int m = 0; m <= MAX_M; m++){
adder.add(new HashMap<Integer, Integer>());
}
memo.add(adder);
}
while (true) {
final int N = sc.nextInt();
final int M = sc.nextInt();
final int S = sc.nextInt();
if (N == 0 && M == 0 && S == 0) {
break;
}
System.out.println(DFS(N * N, M, S));
}
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | ### constant
MOD = 100000
### main
loop do
n, m, s = gets.strip.split(' ').map{|s| s.to_i}
break if (n | m | s) == 0
nn = n * n
dp = (nn + 1).times.map{(s + 1).times.map{0}}
dp[0][0] = 1
for i in (1..m)
nn.downto(1) do |j|
for k in (i..s)
dp[j][k] = (dp[j][k] + dp[j - 1][k - i]) % MOD
end
end
end
puts dp[nn][s]
end |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1},
{-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const int kaijou[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
int main() {
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
static int dp[2002][3002] = {};
for (int i = 0; i < 2002; i++) {
for (int j = 0; j < 3002; j++) {
if (j == 0)
dp[i][j] = 1;
else
dp[i][j] = 0;
}
}
for (int i = 1; i <= n * n; i++) {
for (int j = s + 1 - 1; j >= 0; j--) {
for (int k = 1; k <= min(m, j); k++) {
dp[k][j] = dp[k - 1][j - k];
dp[k][j] %= 100000;
}
for (int k = min(m, j); k <= m; k++) {
dp[k][j] = 0;
}
dp[0][j] = 0;
}
for (int j = 0; j < s + 1; j++) {
for (int k = 1; k <= m; k++) {
dp[k][j] += dp[k - 1][j];
dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int mod = 100000;
int dp[2][50][3001];
void add(int& x, int y) {
x += y;
if (x >= mod) x -= mod;
}
int main() {
while (true) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0) break;
n = n * n;
for (int j = 0; j < (n + 1); ++j)
for (int k = 0; k < (s + 1); ++k) dp[0][j][k] = 0;
dp[0][0][0] = 1;
for (int i = 0; i < (m); ++i) {
for (int j = 0; j < (n + 1); ++j)
for (int k = 0; k < (s + 1); ++k) dp[1 - i % 2][j][k] = 0;
for (int j = 0; j < (n + 1); ++j) {
for (int k = 0; k < (s + 1); ++k) {
add(dp[1 - i % 2][j][k], dp[i % 2][j][k]);
if (j + 1 <= n && k + i + 1 <= s)
add(dp[1 - i % 2][j + 1][k + i + 1], dp[i % 2][j][k]);
}
}
}
cout << dp[m % 2][n][s] << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long hmod1 = 999999937;
const long long hmod2 = 1000000000 + 9;
const long long INF = 1 << 30;
const long long mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
int md = 100000;
int n, m, s;
int dp[2][2005][3005];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
while (true) {
cin >> n >> m >> s;
n = n * n;
if (n == 0) break;
memset(dp, 0, sizeof(dp));
int cur = 1, pre = 0;
dp[pre][0][0] = 1;
for (int i = 0; i < (n); i++) {
memset(dp[cur], 0, sizeof(dp[cur]));
for (int j = (i + 1); j < (m + 1 - (n - 1 - i)); j++)
for (int k = (j); k < (min(j * (j + 1) / 2 + 1, s + 1)); k++) {
((dp[cur][j][k]) =
((dp[cur][j][k]) +
((dp[cur][j - 1][k - 1] + dp[pre][j - 1][k - j]) % md) % md) %
md);
}
swap(cur, pre);
}
int ans = 0;
for (int j = 0; j < (m + 1); j++)
((ans) = ((ans) + (dp[pre][j][s]) % md) % md);
cout << ans << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int x[2000 + 1][3000 + 1];
int y[2000 + 1][3000 + 1];
int z[50][3000];
int sum = 0;
int main() {
int n, m, s, d, e, f, g;
while (true) {
cin >> n >> m >> s;
if ((n == 0 && m == 0) && s == 0) {
break;
}
memset(x, 0, sizeof(x));
memset(y, 0, sizeof(y));
memset(z, 0, sizeof(z));
if (m < s - ((n * n) - 2) * ((n * n) - 1) / 2) {
for (int i = 1; i <= m; i++) {
x[i][i] = 1;
}
for (int i = 2; i <= n * n; i++) {
d = s / (n * n - i + 1);
e = min(m, d);
f = s * i / (n * n) + i - n * n;
g = (i - 2) * (i - 1) / 2;
for (int j = i - 1; j <= e; j++) {
for (int k = j + g; k <= f; k++) {
for (int l = j + 1; l <= e; l++) {
y[l][k + l] += x[j][k];
}
}
}
y[2000][3000] = 0;
for (int j = i; j <= e; j++) {
for (int k = j; k <= s; k++) {
x[j][k] = y[j][k] % 100000;
y[j][k] = 0;
}
}
y[0][0] = 0;
}
for (int i = 0; i <= m; i++) {
sum += x[i][s];
sum %= 100000;
}
} else {
z[0][0] = 1;
for (int i = 1; i <= n * n; i++) {
d = n * n - i + 1;
for (int j = 0; j <= s; j++) {
e = 0;
while (j + e * d <= s) {
z[i][j + e * d] += z[i - 1][j];
z[i][j + e * d] %= 100000;
e++;
}
}
}
sum = z[n * n][s - ((n * n) + 1) * (n * n) / 2] % 100000;
}
cout << sum << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[2005][55][3005];
int main(void) {
int i, j, k;
int n, m, s;
while (1) {
cin >> n >> m >> s;
if (n == 0) break;
for (i = 0; i < (2005); i++)
for (j = 0; j < (55); j++)
for (k = 0; k < (3005); k++) dp[i][j][k] = 0;
dp[0][0][0] = 1;
for (i = 0; i < (m + 1); i++)
for (j = 0; j < (n * n + 1); j++)
for (k = 0; k < (s + 1); k++)
if (dp[i][j][k] > 0) {
(dp[i + 1][j][k] += dp[i][j][k]) %= 100000;
if (k + i + 1 <= s)
(dp[i + 1][j + 1][k + i + 1] += dp[i][j][k]) %= 100000;
}
cout << dp[m][n * n][s] << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int B[2001][50][3001];
int main() {
int N, M, S;
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) break;
for (int i = int(0); i <= int(N * N); i++) {
for (int j = int(0); j <= int(S); j++) {
if (i == 0 && j == 0)
B[0][i][j] = 1;
else
B[0][i][j] = 0;
}
}
int mod = 100000;
for (int n = int(0); n <= int(N * N); n++) {
for (int k = int(0); k <= int(M - 1); k++) {
for (int s = int(0); s <= int(S); s++) {
if (s - (k + 1) >= 0 && n - 1 >= 0)
B[k + 1][n][s] = B[k][n - 1][s - (k + 1)] % mod + B[k][n][s] % mod;
else
B[k + 1][n][s] = B[k][n][s] % mod;
}
}
}
cout << B[M][N * N][S] % mod << endl;
for (int k = int(0); k <= int(M); k++)
for (int n = int(0); n <= int(N * N); n++)
for (int s = int(0); s <= int(S); s++) B[k][n][s] = 0;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | python3 | # AOJ 0537: Bingo
# Python3 2018.7.1 bal4u
while True:
n, m, s = map(int, input().split())
if n == 0: break
n *= n
dp = [[0 for j in range(3001)] for i in range(n+1)]
dp[0][0] = 1
for i in range(1, m+1):
for j in range(n, 0, -1):
for k in range(i, s+1):
dp[j][k] = (dp[j][k]+dp[j-1][k-i]) % 100000;
print(dp[n][s])
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
int dp[2][2001][3001];
int T[2001][3001];
int main() {
while (cin >> N >> M >> S) {
if (N == 0 && M == 0 && S == 0) break;
for (int j = 1; j <= M; j++) {
for (int k = 1; k <= S; k++) {
dp[0][j][k] = 0;
}
}
for (int i = 1; i <= min(M, S); i++) dp[0][i][i] = 1;
for (int i = 0; i < N * N - 1; i++) {
int crnt = i % 2, next = (i + 1) % 2;
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
dp[next][j][k] = 0;
T[j][k] = 0;
}
}
for (int j = i + 1; j <= M; j++) {
for (int k = (i * (i - 1) / 2) + j; k <= S; k++) {
if (dp[crnt][j][k] == 0) continue;
int lb = j + 1;
if (k + lb <= S) {
T[lb][k + lb] = (T[lb][k + lb] + dp[crnt][j][k]) % 100000;
}
}
}
for (int j = 1; j <= M; j++) {
for (int k = 1; k <= S; k++) {
T[j][k] += T[j - 1][k - 1];
dp[next][j][k] += T[j][k];
}
}
}
int m = 0;
for (int i = 1; i <= M; i++) m = (m + dp[(N * N - 1) % 2][i][S]) % 100000;
cout << m << "\n";
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
vector<int> mem[50][2001];
int num(int n, int m, int s) {
if (s < mem[n][m].size() && mem[n][m][s] != 0) {
return mem[n][m][s] - 1;
}
if (n == 1) {
if (s <= m) {
return 1;
} else {
return 0;
}
}
int ret = 0;
for (int i = max(n, (s - (n - 1) * n / 2) / n); i <= m; i++) {
if (s - i < (n - 1) * n / 2) {
break;
}
ret += num(n - 1, i - 1, s - i);
}
ret %= 100000;
if (mem[n][m].size() <= s) {
mem[n][m].resize(min(s * 4 / 3 + 1, 3001));
}
mem[n][m][s] = ret + 1;
return ret;
}
int main() {
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
cout << num(N * N, M, S) << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int dp[50][2001][3001];
int main() {
while (1) {
int i;
int n, m, s;
int square;
int first_val;
int sum;
scanf("%d %d %d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) {
return 0;
}
square = n * n;
first_val = square * (square + 1) / 2;
for (i = 0; i < square + 1; i++) {
int j;
for (j = 0; j < m + 1; j++) {
int k;
for (k = 0; k < s + 1; k++) {
dp[i][j][k] = 0;
}
}
}
dp[square][square][first_val] = 1;
for (i = square; i < m + 1; i++) {
int j;
for (j = first_val; j < s + 1; j++) {
int k;
for (k = 1; k < square + 1; k++) {
int l;
for (l = 1; l <= k; l++) {
if (i + 1 > m || j + l > s) break;
dp[l][i + 1][j + l] += dp[k][i][j];
dp[l][i + 1][j + l] %= 100000;
}
}
}
}
sum = 0;
for (i = 1; i < square + 1; i++) {
int j;
for (j = 1; j < m + 1; j++) {
sum += dp[i][j][s];
sum %= 100000;
}
}
printf("%d\n", sum);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int dp[50][2001][3001];
int main() {
memset(dp, 0, sizeof(dp));
for (int i = 0; i <= 2000; i++) dp[0][i][0] = 1;
for (int i = 1; i <= 2000; i++) {
for (int j = 1; j <= 49; j++) {
for (int k = 0; k <= 3000; k++) {
dp[j][i][k] += dp[j][i - 1][k];
if (k - i >= 0) dp[j][i][k] += dp[j - 1][i - 1][k - i];
dp[j][i][k] %= 100000;
}
}
}
while (1) {
int n, m, s;
scanf("%d %d %d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) return 0;
printf("%d\n", dp[n][m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int i, j, k;
int n, m, s;
int hoge = 0;
while (scanf("%d%d%d", &n, &m, &s), n) {
++hoge;
if (hoge >= 6) exit(1);
}
puts("a");
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S, dp[2001][3001];
int ths(int begin, int end, int count) { return ((begin + end) * count) / 2; }
int main(void) {
for (int i = 0; i < 50; i++) {
for (int ii = 0; ii < 3001; ii++) dp[i][ii] = 0;
}
cin >> N >> M >> S;
dp[0][0] = 1;
int t = ths(1, N * N, N * N);
for (int i = 1; i <= N * N; i++) {
for (int j = 0; j < M - (N * N); j++) {
for (int k = 0; k < S - t; k++) {
if (j < 2000 && k + i < 3001)
dp[j + 1][k + i] = (dp[j + 1][k + i] + dp[j][k]) % 100000;
}
}
}
int result = 0;
for (int i = 0; i <= M - (N * N); i++) {
result = (result + dp[i][S - t]) % 100000;
}
cout << result << endl;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<bits/stdc++.h>
using namespace std;
int dp[2200][3200],_prev[2200][3200],n,m,s;
int main(){
while(true){
cin>>n>>s>>m;if(n==0)return 0;n*=n;
for(int i=0;i<2200;i++){fill(dp[i],dp[i]+3200);fill(_prev[i],_prev[i]+3200);}
for(int i=0;i<=s;i++)_prev[i][0]=1;
for(int i=0;i<n;i++){
for(int j=1;j<=s;j++){
for(int k=j;k<=m;k++){
dp[j][k]+=_prev[j-1][k-j];dp[j][k]%=100000;
}
}
for(int j=0;j<=s;j++){
for(int k=0;k<=m;k++){
_prev[j][k]=dp[j][k];dp[j][k]=0;
}
}
for(int j=1;j<=s;j++){
for(int k=1;k<=m;k++){
_prev[j][k]+=_prev[j-1][k];
}
}
}
cout<<_prev[s][m]%100000<<endl;
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
int dp[2][2001][3001];
int main() {
while (cin >> N >> M >> S) {
if (N == 0 && M == 0 && S == 0) break;
for (int i = 0; i < 2; i++) {
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
dp[i][j][k] = 0;
}
}
}
for (int i = 1; i <= min(M, S); i++) dp[0][i][i] = 1;
for (int i = 0; i < N * N - 1; i++) {
int _ = i % 2;
for (int j = 1; j <= M; j++) {
for (int k = 0; k <= S; k++) {
dp[_ ^ 1][j][k] = 0;
}
}
for (int j = 1; j <= M; j++) {
for (int k = 1; k <= S; k++) {
if (dp[_][j][k] == 0) continue;
int s = N * N - i - 1;
int ss = k + (s - 1) * s / 2;
for (int l = j + 1; l <= min(M, S - k); l++) {
if (ss + s * l > S) break;
dp[_ ^ 1][l][k + l] = (dp[_ ^ 1][l][k + l] + dp[_][j][k]) % 100000;
}
}
}
}
int m = 0;
for (int i = 0; i <= M; i++) m = (m + dp[(N * N - 1) % 2][i][S]) % 100000;
cout << m << "\n";
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, s, ans;
int dp[50][2001][3001];
int main() {
while (cin >> n >> m >> s && n) {
memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;
for (int i = 0; i < n * n; ++i) {
for (int j = 0; j < m; ++j) {
for (int k = 0; k < s; ++k) {
dp[i + 1][j + 1][k + 1] =
(dp[i + 1][j][k] + dp[i][j][k - j]) % 100000;
}
}
}
ans = 0;
for (int i = 0; i <= m; ++i) {
ans += dp[n * n][i][s];
ans %= 100000;
}
cout << ans << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int _dx[] = {0, 1, 0, -1};
const int _dy[] = {-1, 0, 1, 0};
int getInt() {
int ret = 0, c;
c = getchar();
while (!isdigit(c)) c = getchar();
while (isdigit(c)) {
ret *= 10;
ret += c - '0';
c = getchar();
}
return ret;
}
int n, m, second;
int memo[2][2001][3001];
int dp, dp2;
int main() {
while (true) {
n = getInt();
m = getInt();
second = getInt();
if (n + m + second == 0) break;
n = n * n;
dp = 0;
dp2 = 1;
for (int i = 0; i < (int)(n); i++) {
swap(dp, dp2);
memset(memo[dp], 0, sizeof(memo[0]));
if (i == 0) {
for (int x = (1); x < (int)(m + 1); x++) {
int xx = x * n;
if (xx > second) break;
memo[dp][x][xx] = 1;
}
} else {
for (int x = (1); x < (int)(m + 1); x++)
for (int y = (n - i); y < (int)(second + 1); y++) {
memo[dp][x][y] =
(memo[dp][x - 1][y - (n - i)] + memo[dp2][x - 1][y - (n - i)]) %
100000;
}
}
}
int ans = 0;
for (int i = 0; i < (int)(m + 1); i++)
ans = (ans + memo[dp][i][second]) % 100000;
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | import std.algorithm;
import core.stdc.stdio;
void main(){
while(1){
int n,m,s;
scanf("%d%d%d",&n,&m,&s);
if(n==0&&m==0&&s==0)
break;
int[] now = new int[(m+1)*(s+1)];
int[] next = new int[(m+1)*(s+1)];
now[0] = 1;
int minM=0;
int minS=0;
for(int _=0;_<n*n;_++){
next[] = 0;
int nmm = 114514;
int nms = 114514;
for(int k=1;k<=m;k++){
for(int j=minS;j+k*(n*n-_)<=s;j++){
int ns = j+k*(n*n-_);
for(int i=minM;i+k<=m;i++){
int nm = i+k;
nmm = min(nmm,nm);
nms = min(nms,ns);
next[nm*(s+1)+ns] = (next[nm*(s+1)+ns]+now[i*(s+1)+j])%100000;
}
}
}
swap(now,next);
minM = nmm;
minS = nms;
}
int ans=0;
for(int i=1;i<=m;i++)
ans = (ans+now[i*(s+1)+s])%100000;
printf("%d\n",ans);
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int M;
int *done;
int *memo;
int num(int i, int N, int S) {
if (S < 0) {
return (0);
}
if (done[i * 50 * 3100 + N * 3100 + S]) {
return (memo[i * 50 * 3100 + N * 3100 + S]);
}
if (N == 0) {
return (S == 0);
}
if (i > M) {
return (0);
}
done[i * 50 * 3100 + N * 3100 + S] = 1;
memo[i * 50 * 3100 + N * 3100 + S] =
(num(i + 1, N - 1, S - i) + num(i + 1, N, S)) % 100000;
return (memo[i * 50 * 3100 + N * 3100 + S]);
}
int main(void) {
int N, S;
done = (int *)malloc(1100 * 50 * 3100 + 50 * 3100 + 3100);
memo = (int *)malloc(1100 * 50 * 3100 + 50 * 3100 + 3100);
while (1) {
scanf("%d %d %d", &N, &M, &S);
if (!N && !M && !S) {
break;
}
memset(done, 0, sizeof(done));
printf("%d\n", num(1, N * N, S) % 100000);
}
free(memo);
free(done);
return (0);
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
int dp[50][2001][3001];
int main() {
while (cin >> N >> M >> S) {
if (N == 0 && M == 0 && S == 0) break;
for (int i = 0; i < N * N; i++) {
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
dp[i][j][k] = 0;
}
}
}
for (int i = 1; i <= min(M, S); i++) dp[0][i][i] = 1;
for (int i = 0; i < N * N; i++) {
for (int j = 1; j <= M; j++) {
for (int k = 0; k <= S; k++) {
if (dp[i][j][k] == 0) continue;
for (int l = j + 1; l <= min(M, S - k); l++) {
dp[i + 1][l][k + l] += dp[i][j][k];
dp[i + 1][l][k + l] %= 100000;
}
}
}
}
int m = 0;
for (int i = 0; i <= M; i++) m = (m + dp[N * N - 1][i][S]) % 100000;
cout << m << "\n";
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
vector<int> mem[50][2001];
int num(int n, int m, int s) {
if (n == 2) {
if (s > m) {
if (m > s - m) {
return (m - (s - m) + 1) / 2;
} else {
return 0;
}
} else {
return (s - 1) / 2;
}
} else if (n == 1) {
if (s <= m) {
return 1;
} else {
return 0;
}
}
if (s < mem[n][m].size() && mem[n][m][s] != 0) {
return mem[n][m][s] - 1;
}
int ret = 0;
for (int i = max(n, (s - (n - 1) * n / 2) / n); i <= m; i++) {
if (s - i < (n - 1) * n / 2) {
break;
}
ret += num(n - 1, i - 1, s - i);
}
ret %= 100000;
if (mem[n][m].size() <= s) {
mem[n][m].resize(min(s + 1, 3001));
}
mem[n][m][s] = ret + 1;
return ret;
}
int main() {
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
cout << num(N * N, M, S) << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int mod = 100000;
int dp[2][50][3001];
int main() {
while (true) {
int N, M, S;
scanf("%d%d%d", &N, &M, &S);
if (N == 0 && M == 0 && S == 0) break;
N *= N;
memset(dp, 0, sizeof(dp));
int t = 0;
dp[1 - t][0][0] = 1;
for (int i = 0; i < M; i++) {
for (int j = 0; j <= N; j++)
for (int k = 0; k <= S; k++) dp[t][j][k] = 0;
for (int j = 0; j <= N; j++)
for (int k = 0; j + k <= S; k++) {
if (k + j <= S) {
dp[t][j][j + k] += dp[1 - t][j][k];
if (dp[t][j][j + k] >= mod) dp[t][j][j + k] -= mod;
}
if (k + j + 1 <= S) {
dp[t][j + 1][j + k + 1] += dp[1 - t][j][k];
if (dp[t][j + 1][j + k + 1] >= mod) dp[t][j + 1][j + k + 1] -= mod;
}
}
t = 1 - t;
}
printf("%d\n", dp[1 - t][N][S]);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
while (true) {
int N, M, S;
cin >> N >> M >> S;
if (N == 0) return 0;
M = min(M, S);
int dp[50][3001];
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 3001; j++) {
dp[i][j] = 0;
}
}
dp[0][0] = 1;
for (int i = 1; i <= N * N; i++) {
for (int j = i; j <= S; j++) {
if (j >= i) dp[i][j] = dp[i - 1][j - i] + dp[i][j - i];
if (j > M) dp[i][j] -= dp[i - 1][j - M - 1];
dp[i][j] %= 100000;
}
}
cout << dp[N * N][S] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1},
{-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const int kaijou[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
int main() {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
static int dp[2002][3002] = {};
for (int i = 0; i < 2002; i++) dp[i][0] = 1;
for (int i = 1; i <= n * n; i++) {
for (int j = s + 1 - 1; j >= 0; j--) {
for (int k = 1; k <= m; k++) {
if (j >= k) {
dp[k][j] = dp[k - 1][j - k];
} else
dp[k][j] = 0;
dp[k][j] %= 100000;
}
dp[0][j] = 0;
}
for (int j = 0; j < s + 1; j++) {
for (int k = 1; k <= m; k++) {
dp[k][j] += dp[k - 1][j];
dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[m][s]);
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int dp[50][3001];
int main() {
int n, m, s;
while (scanf("%d %d %d", &n, &m, &s), n) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 1; i <= m; i++)
for (int j = n * n; j >= 1; j--)
for (int k = m; k <= s; k++) {
dp[j][k] += dp[j - 1][k - i];
if (dp[j][k] >= 100000) dp[j][k] -= 100000;
}
printf("%d\n", dp[n * n][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1},
{-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const int kaijou[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
int main() {
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
static int dp[2002][3002] = {};
for (int i = 0; i < 2002; i++) {
for (int j = 0; j < 3002; j++) {
if (j == 0)
dp[i][j] = 1;
else
dp[i][j] = 0;
}
}
int l = 0, r;
for (int i = 1; i <= n * n; i++) {
l += i;
r = s;
for (int j = i + 1; j <= n * n; j++) {
r -= j;
}
for (int j = r; j >= l; j--) {
dp[i - 1][j] = 0;
for (int k = i; k <= m && k * (n * n - i + 1) <= s; k++) {
dp[k][j] = dp[k - 1][j - k];
if (dp[k][j] >= 100000) dp[k][j] %= 100000;
}
for (int k = min(m, j) + 1; k <= m && k * (n * n - i + 1) <= s; k++) {
dp[k][j] = 0;
}
dp[0][j] = 0;
}
for (int j = l - i; j < l; j++) {
for (int k = 1; k <= m; k++) {
dp[k][j] = 0;
}
dp[0][j] = 0;
}
for (int j = l; j <= r; j++) {
for (int k = i; k <= m && k * (n * n - i + 1) <= s; k++) {
dp[k][j] += dp[k - 1][j];
if (dp[k][j] >= 100000) dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
int dp[2][3001][2001];
const int MOD = 100000;
int main() {
while (cin >> N >> M >> S, N * M) {
for (int i = 1; i <= S; i++) {
dp[0][i][i] = 1;
}
for (int i = 0; i < N * N - 1; i++) {
for (int j = 1; j <= S; j++) {
for (int k = 1; k <= j; k++) {
for (int l = k + 1; l <= M; l++) {
if (j + l <= S) {
dp[(i + 1) % 2][j + l][l] += dp[i % 2][j][k];
dp[(i + 1) % 2][j + l][l] %= MOD;
}
}
dp[i % 2][j][k] = 0;
}
}
}
int ans = 0;
for (int i = 1; i <= M; i++) {
ans += dp[(N * N - 1) % 2][S][i];
}
cout << ans % MOD << endl;
for (int i = 0; i <= 1; i++)
for (int j = 1; j <= S; j++)
for (int k = 1; k <= M; k++) dp[i][j][k] = 0;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
while (true) {
int N, M, S;
cin >> N >> M >> S;
if (N == 0) return 0;
int dp[50][3001];
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 3001; j++) {
dp[i][j] = 0;
}
}
dp[0][0] = 1;
for (int i = 1; i <= M; i++) {
for (int j = 1; j <= N * N; j++) {
for (int k = i; k <= S; k++) {
dp[j][k] += dp[j - 1][k - i];
dp[j][k] %= 100000;
}
}
}
cout << dp[N * N][S] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s;
while (cin >> n >> m >> s) {
if (n == 0 && m == 0 && s == 0) break;
int dp[2][2002][3002];
for (long long i = 0; i < (long long)(2); i++)
for (long long j = 0; j < (long long)(2002); j++)
for (long long k = 0; k < (long long)(3002); k++) dp[i][j][k] = 0;
dp[0][0][0] = 1;
for (int i = 1; i <= n * n; i++) {
for (int j = 0; j <= m; j++)
for (int k = 0; k <= s; k++) dp[i % 2][j][k] = 0;
for (int j = 1; j <= m; j++) {
for (int k = 1; k <= s; k++) {
if (k - j >= 0) {
dp[i % 2][j][k] +=
dp[i % 2][j - 1][k - 1] + dp[(i - 1) % 2][j - 1][k - j];
dp[i % 2][j][k] %= 100000;
}
}
}
}
long long ans = 0;
for (int i = 0; i <= m; i++) {
ans += dp[(n * n) % 2][i][s];
ans %= 100000;
}
cout << ans << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)
using namespace std;
typedef unsigned int uint;
typedef long long ll;
int getInt(){
int ret = 0,c;
c = getchar();
while(!isdigit(c)) c = getchar();
while(isdigit(c)){
ret *= 10;
ret += c - '0';
c = getchar();
}
return ret;
}
#define MOD 100000
int n,m,s;
int memo[2001][3001];
int prevs[2][3001];
int *prev, *prev2;
int dp,dp2;
int main(){
while(true){
n = getInt();
m = getInt();
s = getInt();
if(n+m+s == 0) break;
n = n * n;
prev = prevs[0];
prev2 = prevs[1];
REP(i,n){
if(i == 0){
REP(k,m+1) REP(j,s+1) memo[k][j] = 0;
rep(x,1,m+1){
int xx = x * n;
if(xx > s) break;
memo[x][xx] = 1;
}
}else{
memset(prev,0,sizeof(int)*s);
if(i % 15 == 0){
rep(x,1,m+1){
memcpy(prev2,memo[x],sizeof(int)*s);
rep(y,n-i,s+1){
memo[x][y] = (memo[x-1][y-(n-i)] +
prev[y-(n-i)]) % MOD;
}
swap(prev,prev2);
}
}else{
rep(x,1,m+1){
memcpy(prev2,memo[x],sizeof(int)*s);
rep(y,n-i,s+1){
memo[x][y] = (memo[x-1][y-(n-i)] +
prev[y-(n-i)]);
}
int *tmp = prev;
prev = prev2;
prev2 = tmp;
}
}
}
}
int ans = 0;
REP(i,m+1) ans = (ans + memo[i][s]) % MOD;
print(ans);
}
return 0;
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int bingo[2001][3001];
int main() {
int works1[3001];
int works2[3001];
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0) return 0;
memset(bingo, '\0', sizeof(bingo));
for (int k = 1; k <= m; k++)
if (k * n * n <= s)
bingo[k][k * (n * n)] = 1;
else
break;
int i, j, k;
for (i = 2; i <= n * n; i++) {
int ex = n * n - i + 1;
int start = i * (i - 1) / 2;
for (j = i - 1; j < m; j++) {
memcpy(works2, works1, sizeof(works1));
memcpy(works1, bingo[j + 1], sizeof(works2));
for (k = start; k + ex <= s; k++) {
int tmp = bingo[j][k] + works2[k];
if (!(bingo[j + 1][k + ex] + tmp)) continue;
bingo[j + 1][k + ex] = tmp % 100000;
}
}
}
int result = 0;
for (i = n * n; i <= m; i++) result = (result + bingo[i][s]) % 100000;
printf("%d\n", result);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
map<pair<int, int>, Mod> mp;
mp[make_pair(0, rest)] = 1;
for (int i = 0; i < asize; ++i) {
map<pair<int, int>, Mod> nextmp;
for (auto m : mp) {
int least = m.first.first;
int arest = m.first.second;
for (int n = least; n <= min(M - asize, arest / (asize - i)); ++n) {
nextmp[make_pair(n, arest - n)] += m.second;
}
}
mp = nextmp;
}
Mod ans = 0;
for (auto m : mp) {
if (m.first.second == 0) ans += m.second;
}
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <iostream>
#include <cstring>
using namespace std;
int dp[59][3001];
int main(void)
{
while(1)
{
int num,max,sum;
cin >> num >> max >> sum;
if(num+max+sum == 0)
return 0;
memset(dp,0,sizeof(dp));
dp[0][0] = 1;
for(int m=1;m<=max;++m)//その数を使ッた時のあれ
{
for(int n=num*num;n>=1;--n)//どの数が使う?(num
{
for(int i=m;i<=sum;++i){//どの数が使う?(sum
dp[n][i] += dp[n-1][i-m];//mを使った時の通り数を足す
dp[n][i] %= 100000;
}
}
}
cout << dp[num*num][sum] << endl;
}
return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
int dp[59][3001];
int main(void)
{
while(1)
{
int num,max,sum;
cin >> num >> max >> sum;
if(num+max+sum == 0)
return 0;
memset(dp,0,sizeof(dp));
dp[0][0] = 1;
for(int m=1;m<=max;++m)//その数を使ッた時のあれ
{
for(int n=num*num;n>=1;--n)//どの数が使う?(num
{
for(int i=m;i<=sum;++i){//どの数が使う?(sum
dp[n][i] += dp[n-1][i-m];//mを使った時の通り数を足す
dp[n][i] %= 100000;
}
}
}
cout << dp[num*num][sum] << endl;
}
return 0;
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
int dp[2010][50][3010];
int main() {
while (true) {
cin >> N >> M >> S;
if (N == 0) break;
for (int i = 0; i < 2010; i++) {
for (int j = 0; j < 50; j++) {
for (int k = 0; k < 3010; k++) {
dp[i][j][k] = 0;
}
}
}
dp[0][0][0] = 1;
for (int i = 0; i <= M; i++) {
for (int s = 0; s <= S; s++) {
for (int k = 0; k < N * N; k++) {
dp[i + 1][k][s] = (dp[i + 1][k][s] + dp[i][k][s]) % 100000;
if (k + 1 <= N * N && s + i + 1 <= S) {
dp[i + 1][k + 1][s + i + 1] =
(dp[i + 1][k + 1][s + i + 1] + dp[i][k][s]) % 100000;
}
}
}
}
int ans = 0;
for (int i = 0; i <= M; i++) {
ans = (ans + dp[i][N * N][S]) % 100000;
}
cout << ans << "\n";
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
unsigned short dp[162617];
int main(void) {
int i, j, k;
int n, m, s;
while (scanf("%d%d%d", &n, &m, &s), n) {
n *= n;
dp[0] = 0;
dp[1] = 0x8000;
for (i = 2; i < 162617; ++i) dp[i] = 0;
for (i = 1; i <= m; ++i) {
for (j = n; j >= 0; --j) {
for (k = s; k >= 0; --k) {
if (j && i <= k) {
int a = j * 3001 + k, b = (j - 1) * 3001 + k - i;
int tmp = (((((dp[a + (a >> 4)] & ((1 << (16 - (a & 15))) - 1)))
<< ((a & 15) + 1)) +
(dp[a + (a >> 4) + 1] >> (15 - (a & 15)))) +
((dp[b + (b >> 4)] & ((1 << (16 - (b & 15))) - 1))
<< (((b & 15) + 1))) +
(dp[b + (b >> 4) + 1] >> (15 - (b & 15)))) %
100000;
dp[a + a / 16] &= 0xffff - (1 << (16 - (a & 15))) + 1;
dp[a + a / 16] |= tmp >> ((a & 15) + 1);
dp[a + a / 16 + 1] &= (1 << (15 - (a & 15))) - 1;
dp[a + a / 16 + 1] |= tmp << (15 - (a & 15));
}
}
}
}
int a = n * 3001 + s;
a = (((dp[a + a / 16] & ((1 << (16 - a % 16)) - 1))) << (a % 16 + 1)) +
(dp[a + a / 16 + 1] >> (15 - a % 16));
printf("%d\n", a);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
int n, m, s;
int dp[2][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s), n) {
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[0][j][k] = 0;
dp[0][0][0] = 1;
m = min(m, s);
int cur = 0, next = 1;
for (int i = 1; i <= n * n; i++) {
for (int j = 0; j < 2; j++)
for (int k = 0; k < s + 1; k++) dp[next][i - 1 + j][k] = 0;
for (int j = i - 1; j < m; j++)
for (int k = n * n - i + 1; k <= s; k++) {
dp[next][j + 1][k] = dp[cur][j][k - (n * n - i + 1)] +
dp[next][j][k - (n * n - i + 1)];
if (dp[next][j + 1][k] > 100000) dp[next][j + 1][k] -= 100000;
}
swap(cur, next);
}
int ans = 0;
for (int i = 0; i < m + 1; i++) ans += dp[cur][i][s];
printf("%d\n", ans % 100000);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int mod = 100000;
int dp[3000][2000][49];
int n, m, s;
int main() {
while (1) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
memset(dp, -1, sizeof(dp));
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const long long MOD = 100000;
struct edge {
long long to, cost;
edge(int t, long long c) : to(t), cost(c) {}
};
int dxk[] = {1, 1, 1, 0, -1, 0};
int dxg[] = {0, 1, 0, -1, -1, -1};
int dy[] = {-1, 0, 1, 1, 0, -1};
int bitcount(int a) {
int ret = 0;
while (a != 0) {
ret++;
a = (a - 1) & a;
}
return ret;
}
int dp[2][2001][3001];
int main() {
int n, m;
while (cin >> n >> m && n) {
int s;
cin >> s;
memset(dp, 0, sizeof(dp));
int now = 0;
dp[now][0][0] = 1;
for (int i = 0; i < n * n; i++) {
for (int l = i * (i - 1) / 2; l + i + 1 <= s; l++) {
for (int j = i; j <= m; j++) {
for (int k = 1; j + k <= m; k++) {
dp[!now][j + k][l + j + k] += dp[now][j][l] % MOD;
}
}
}
memset(dp[now], 0, sizeof(dp[now]));
now = !now;
}
int ans = 0;
for (int i = 0; i < (int)m + 1; ++i) ans = (ans + dp[now][i][s]) % MOD;
cout << ans << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int N, M, S, B[81], dp[81][2005][3005];
int dfs(int d, int m, int s) {
int i, r = 0;
if (dp[d][m][s] != -1) return dp[d][m][s];
if (d > N * N || m > M || s > S) return 0;
if (d == N * N && s == S) return 1;
for (i = m + 1; i <= M && s + i <= S; i++) {
B[d] = i;
r = (r + dfs(d + 1, i, s + i)) % 100000;
}
return dp[d][m][s] = r;
}
int main() {
for (; scanf("%d%d%d", &N, &M, &S), N;) {
memset(dp, -1, sizeof(dp));
printf("%d\n", dfs(0, 0, 0));
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[3005][50] = {};
int n, m, s;
int main() {
while (1) {
scanf("%d %d %d", &n, &m, &s);
if (!n) break;
dp[0][0] = 1;
for (int i = 1; i <= m; i++) {
for (int k = i; k <= s; k++) {
for (int j = 1; j <= n * n; j++) {
dp[k][j] += dp[k - i][j - 1];
dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[s][n * n]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
static const long long INF = 1LL << 61LL;
static const double EPS = 1e-8;
static const int mod = 100000;
int N, M, S;
int mem[50][500][3001];
long long cal(int n, int mx, int sum) {
long long res = 0;
if (sum > S) return 0;
if (mem[n][mx][sum] != -1) return mem[n][mx][sum];
if (n == N * N) {
if (sum == S) {
return 1;
} else
return 0;
}
for (int i = mx + 1; i <= M; ++i) {
if (sum + i > S) break;
res += cal(n + 1, i, sum + i);
}
return mem[n][mx][sum] = res % mod;
}
int main() {
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) break;
memset(mem, -1, sizeof(mem));
cout << cal(0, 0, 0) << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[50][2001][3001];
int main(void) {
int ans = 0;
int N, M, S;
while (scanf("%d%d%d", &N, &M, &S), N) {
for (int i = 1; i <= M; i++) {
dp[1][i][i] = 1;
}
for (int i = 1; i <= N * N; i++) {
for (int j = i; j <= M; j++) {
for (int k = j + i - 1; k <= S; k++) {
dp[i][j][k] += dp[i][j - 1][k - 1];
dp[i][j][k] %= 100000;
dp[i][j][k] += dp[i - 1][j - 1][k - j];
dp[i][j][k] %= 100000;
}
}
}
for (int j = 1; j <= M; j++) {
ans += dp[N * N][j][S];
ans %= 100000;
}
cout << ans << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
vector<vector<Mod>> mp(M + 1, vector<Mod>(rest + 1));
mp[0][rest] = 1;
int amax = 0;
int amin = rest;
for (int i = 0; i < asize; ++i) {
vector<vector<Mod>> nextmp(M + 1, vector<Mod>(rest + 1));
int aamax = amax;
int aamin = amin;
for (int j = 0; j <= amax; ++j) {
for (int k = aamin; k < mp[j].size(); ++k) {
if (mp[j][k].num) {
const int least = j;
const int arest = k;
for (int n = least; n <= min(M - asize, arest / (asize - i));
++n) {
nextmp[n][arest - n] += mp[j][k];
aamax = max(aamax, n);
aamin = min(aamin, arest - n);
}
aamax = max(aamax, (min(M - asize, arest / asize - i)));
aamin = min(aamin, arest - min(M - asize, arest / (asize - i)));
}
}
}
amin = min(aamin, amin);
amax = max(aamax, amax);
mp = nextmp;
}
Mod ans = 0;
for (int i = 0; i < mp.size(); ++i) ans += mp[i][0];
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int dp1[50][3001];
int dp2[50][3001];
int mod = 100000;
int n, m, s;
while (scanf("%d%d%d", &n, &m, &s)) {
if (n == 0 && m == 0 && s == 0) break;
memset(dp1, 0, sizeof(dp1));
dp1[0][0] = 1;
for (int i = 1; i <= m; i++) {
memset(dp2, 0, sizeof(dp2));
for (int j = 0; j < n * n + 1; j++) {
for (int k = 0; k < s + 1; k++) {
if (j < n * n && k + i <= s) {
dp2[j + 1][k + i] += dp1[j][k];
dp2[j + 1][k + i] %= mod;
}
dp2[j][k] += dp1[j][k];
dp2[j][k] %= mod;
}
}
for (int j = 0; j < n * n + 1; j++) {
for (int k = 0; k < s + 1; k++) {
dp1[j][k] = dp2[j][k];
}
}
}
printf("%d\n", dp1[n * n][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int mod = 100000;
int N, M, S;
int dp[2009][3009];
int dpsum[2009][3009];
int main() {
while (true) {
scanf("%d%d%d", &N, &M, &S);
if (N == 0 && M == 0 && S == 0) break;
dp[0][0] = 1;
for (int i = 1; i <= N * N; i++) {
for (int j = 0; j <= M; j++) {
for (int k = i * (i - 1) / 2; k <= S; k++) {
if (j != 0) {
dpsum[j][k] = dpsum[j - 1][k] + dp[j][k];
if (dpsum[j][k] >= mod) dpsum[j][k] -= mod;
} else {
dpsum[j][k] = dp[j][k];
}
}
}
for (int j = 0; j <= M; j++) {
for (int k = j; k <= S; k++) {
dp[j][k] = 0;
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S - j - 1; k++) {
dp[j + 1][j + k + 1] = dpsum[j][k];
dpsum[j][k] = 0;
}
}
}
int ans = 0;
for (int j = 1; j <= M; j++) {
ans += dp[j][S];
ans %= mod;
}
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int main() {
while (1) {
int i;
int n, m, s;
unsigned int dp[2][2001][3001];
unsigned int sum;
scanf("%d %d %d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) return 0;
for (i = 0; i < 2; i++) {
int j;
for (j = 1; j <= m; j++) {
int k;
for (k = 1; k <= s; k++) {
if (i == 0 && j == k) {
dp[i][j][k] = 1;
} else {
dp[i][j][k] = 0;
}
}
}
}
for (i = 1; i < n * n; i++) {
int j;
for (j = 1; j <= m; j++) {
int k;
for (k = 1; k <= s; k++) {
int t;
for (t = 1; t * (i + 1) < k; t++) {
if (j > t) {
dp[1][j][k] += dp[0][j - t][k - t * (i + 1)];
dp[1][j][k] %= 100000;
} else {
break;
}
}
}
}
for (j = 1; j <= m; j++) {
int k;
for (k = 1; k <= s; k++) {
dp[0][j][k] = dp[1][j][k];
dp[1][j][k] = 0;
}
}
}
sum = 0;
for (i = 0; i <= m; i++) {
sum += dp[0][i][s];
sum %= 100000;
}
printf("%u\n", sum);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | using namespace std;
#define SUM 30010
#define DIV 100000
int table[49][SUM]={0};
int solve(int N,int M,int S){
for(int i=0;i<N;i++)
for(int j=0;j<=S;j++)table[i][j]=0;
for(int i=1;i<=M;i++){
for(int j=N-1;j>=0;j--){
for(int k=1;k<S;k++){
if ( table[j][k] == 0)continue;
if ( k+i >S)break;
table[j+1][i+k]= (table[j+1][i+k]+table[j][k])%DIV;
}
}
table[0][i]=1;
}
return table[N-1][S];
}
main(){
int n,m,s;
while(cin>>n>>m>>s && n){
cout << solve(n*n,m,s) << endl;
}
return false;
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int dp[7][7][3000][2000];
int main() {
int n, m, s;
cin >> n >> m >> s;
memset(dp, 0, sizeof(dp));
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, s;
int d[501][50][501] = {};
int dp(int a, int b, int c) {
if (a <= 500 && c <= 500) {
if (d[a][b][c]) {
return d[a][b][c];
}
}
if (a <= 0 && b != n * n) {
return 0;
}
if (c > m - (n * n - b)) {
return 0;
}
if (b > n * n) {
return 0;
}
int ans = 0;
for (int i = c + 1; i <= a; i++) {
ans += (dp(a - i, b + 1, i)) % 100000;
ans %= 100000;
}
if (a <= 500 && c <= 500) d[a][b][c] = ans % 100000;
return ans % 100000;
}
int main() {
while (1) {
scanf("%d %d %d", &n, &m, &s);
printf("%d\n", dp(s, 0, 0));
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF_LL 1e18
#define INF 1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
using namespace std;
using ll = long long;
using PII = pair<int, int>;
class Union_find{
private:
vector<int> par;
vector<int> rank;
int n;
public:
Union_find(int a){
n = a;
for(int i = 0;i < n;i++){
par.push_back(i);
rank.push_back(0);
}
}
int find(int x){
if(par[x] == x){
return x;
}else{
return par[x] = find(par[x]);
}
}
void unite(int x, int y){
x = find(x);
y = find(y);
if(x == y) return;
if(rank[x] < rank[y]){
par[x] = y;
}else{
par[y] = x;
if(rank[x] == rank[y]) rank[x]++;
}
}
bool same(int x, int y){
return find(x) == find(y);
}
};
ll dp[50][2020][3030] = {};
int main(void){
int N, M, S;
while(cin >> N >> M >> S && N && M && S){
memset(dp, 0, sizeof dp);
FOR(i, 1, M+1){
dp[1][i][i] = 1;
}
FOR(i, 2, N*N+1){
FOR(j, i, M+1){
FOR(k, (i*(i+1))/2, S+1){
REP(s, min(k+1, j)){
if(k >= j){
dp[i][j][k] += dp[i-1][s][k-j];
dp[i][j][k] = dp[i][j][k] % 100000;
}
}
}
}
}
ll res = 0;
REP(i, M+1){
res += dp[N*N][i][S];
res = res % 100000;
}
cout << res << endl;
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int M = 100000;
int main() {
int n, m, s, dp[50][3001];
while (cin >> n >> m >> s && (n | m | s)) {
fill(dp[0], dp[50], 0);
dp[0][0] = 1;
for (int k = 1; k <= m; k++) {
for (int i = n * n; i > 0; i--) {
for (int j = i; j <= s; j++) {
dp[i][j] = (dp[i][j] + dp[i - 1][j - k]) % M;
}
}
}
cout << dp[n * n][s] << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int surplus = 100000;
int n, m, s, sum, N, ans;
int b[50][3001][2001];
int main() {
for (int i = (1); i < (2001); i++) {
b[1][i][i] = 1;
}
for (int i = (1); i < (50); i++) {
for (int j = (i); j < (3001); j++) {
for (int k = (i - 1); k < (3001); k++) {
if (j > k && j - k <= 2000) {
for (int l = (i - 1); l < (2001); l++) {
if (j - k > l) {
b[i][j][j - k] += b[i - 1][k][l];
}
}
b[i][j][j - k] %= surplus;
}
}
}
}
while (cin >> n >> m >> s) {
if (!n && !m && !s) return 0;
N = n * n;
for (int i = (1); i < (m + 1); i++) {
ans += b[N][s][i];
}
cout << ans % surplus << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[50][2][3001];
int main() {
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0) break;
int t1 = 0, t2 = 1;
n *= n;
for (int i = 0; i < 50; i++)
for (int j = 0; j < 2; j++)
for (int k = 0; k < s + 1; k++) dp[i][j][k] = 0;
dp[0][0][0] = 1;
for (int j = 1; j <= m; j++) {
for (int i = 0; i < n + 1; i++) {
for (int k = 0; k < s + 1; k++) {
dp[i][t2][k] = 0;
}
}
dp[0][t2][0] = 1;
for (int i = 1; i <= n; i++) {
for (int k = 0; k < s + 1; k++) {
if (k - j >= 0) {
dp[i][t2][k] += dp[i - 1][t1][k - j];
}
dp[i][t2][k] += dp[i][t1][k];
if (dp[i][t2][k] < 0) puts("AAAAAAA");
dp[i][t2][k] %= 100000;
}
}
swap(t1, t2);
}
printf("%d\n", dp[n][t1][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1},
{-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const int kaijou[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
int main() {
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
static int dp[2002][3002] = {};
for (int i = 0; i < 2002; i++) {
for (int j = 0; j < 3002; j++) {
if (j == 0)
dp[i][j] = 1;
else
dp[i][j] = 0;
}
}
int l = 0, r;
for (int i = 1; i <= n * n; i++) {
l += i;
r = n * n;
for (int j = i + 1; j <= n * n; j++) {
r -= j;
}
for (int j = r; j >= l; j--) {
for (int k = 1; k <= m; k++) {
if (j >= k) {
dp[k][j] = dp[k - 1][j - k];
} else
dp[k][j] = 0;
if (dp[k][j] >= 100000) dp[k][j] %= 100000;
}
dp[0][j] = 0;
}
for (int j = l - i; j < l; j++) {
for (int k = 1; k <= m; k++) {
dp[k][j] = 0;
}
dp[0][j] = 0;
}
for (int j = 0; j < s + 1; j++) {
for (int k = 1; k <= m; k++) {
dp[k][j] += dp[k - 1][j];
if (dp[k][j] >= 100000) dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[2][3001][50];
const int mod = 100000;
int n, m, s;
int main() {
while (cin >> n >> m >> s && (n | m | s)) {
memset(dp, 0, sizeof(dp));
for (int i = m; i >= 0; i--) {
for (int j = 0; j <= s; j++) {
for (int k = n * n; k >= 0; k--) {
int cur = (i + 1) % 2;
int nxt = i % 2;
int res = 0;
if (k == n * n) {
if (j == 0 && i <= 1) res = 1;
} else {
res += dp[cur][j][k];
if (j - i >= 0) res += dp[cur][j - i][k + 1];
}
dp[nxt][j][k] = res % mod;
}
}
}
cout << dp[1][s][0] % mod << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
long long dp[2][2001][3001];
int min(int a, int b) { return a < b ? a : b; }
int main() {
int n, m, s;
int i, j, k, l;
while (1) {
scanf("%d %d %d", &n, &m, &s);
if (n == 0) return 0;
for (i = 0; i <= m; i++)
for (j = 0; j <= s; j++) dp[1][i][j] = 0;
dp[1][0][0] = 1;
for (i = 0; i < n * n; i++) {
for (j = 0; j <= m; j++)
for (k = 0; k <= s; k++) dp[i % 2][j][k] = 0;
for (j = (i + 1) * (i + 2) / 2; j <= s; j++) {
int u;
if (i == n * n - 1)
u = m;
else
u = min(m, (s - j) / (n * n - i - 1) - (n * n - i) / 2);
for (k = i; k < u; k++) {
for (l = k + 1; l <= u; l++) {
if (j >= l)
dp[i % 2][l][j] =
(dp[i % 2][l][j] + dp[(i + 1) % 2][k][j - l]) % 100000;
}
}
}
}
long long ans = 0;
for (i = n; i <= m; i++) ans = (ans + dp[(n * n - 1) % 2][i][s]) % 100000;
printf("%lld\n", ans);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
int n, m, s, table[2][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s), s) {
n *= n;
for (int i = 1; i <= m; i++)
for (int j = 1; j <= n; j++) table[0][i][j] = (i >= j) ? 1 : 0;
for (int i = 1; i < n; i++) {
for (int j = 1; j <= m; j++) {
for (int k = 1; k <= s; k++) {
if ((j * 2 - i) * (i + 1) / 2 < k || j == 1)
table[i & 1][j][k] = 0;
else if (k <= j)
table[i & 1][j][k] = table[i & 1][j - 1][k];
else
table[i & 1][j][k] =
(table[i & 1][j - 1][k] + table[~i & 1][j - 1][k - j]) % 100000;
}
}
}
n = !printf("%d\n", table[~n & 1][m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int i, j, k;
int n, m, s;
int hoge = 0;
while (scanf("%d%d%d", &n, &m, &s), n) {
++hoge;
if (hoge >= 4) exit(1);
}
puts("a");
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
while (true) {
int N, M, S;
cin >> N >> M >> S;
if (N == 0) return 0;
int dp[50][3001];
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 3001; j++) {
dp[i][j] = 0;
}
}
dp[0][0] = 1;
for (int i = 1; i <= M; i++) {
for (int j = N * N; j >= 1; j--) {
for (int k = i; k <= S; k++) {
dp[j][k] += dp[j - 1][k - i];
dp[i][k] %= 100000;
}
}
}
cout << dp[N * N][S] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1},
{-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const int kaijou[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
int main() {
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
static int dp[2002][3002] = {};
for (int i = 0; i < 2002; i++) {
for (int j = 0; j < 3002; j++) {
if (j == 0)
dp[i][j] = 1;
else
dp[i][j] = 0;
}
}
int l = 0, r;
for (int i = 1; i <= n * n; i++) {
l += i;
r = s;
for (int j = i + 1; j <= n * n; j++) {
r -= j;
}
for (int j = r; j >= l; j--) {
dp[i - 1][j] = 0;
int k = i;
for (; k <= min(m, j) && k * (n * n - i + 1) <= s; k++) {
dp[k][j] = dp[k - 1][j - k];
if (dp[k][j] >= 100000) dp[k][j] %= 100000;
}
for (; k <= m && k * (n * n - i + 1) <= s; k++) {
dp[k][j] = 0;
}
dp[0][j] = 0;
}
for (int j = l - i; j < l; j++) {
for (int k = 1; k <= m; k++) {
dp[k][j] = 0;
}
dp[0][j] = 0;
}
for (int j = l; j <= r; j++) {
for (int k = i; k <= m && k * (n * n - i + 1) <= s; k++) {
dp[k][j] += dp[k - 1][j];
if (dp[k][j] >= 100000) dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
vector<vector<Mod>> mp(M - asize + 1, vector<Mod>(rest + 1));
mp[0][rest] = 1;
int amax = 0;
int amin = rest;
for (int i = 0; i < asize; ++i) {
vector<vector<Mod>> nextmp(M - asize + 1, vector<Mod>(rest + 1));
int aamax = amax;
int aamin = amin;
for (int j = 0; j <= amax; ++j) {
for (int k = amin; k < mp[j].size(); ++k) {
if (mp[j][k].num) {
for (int n = j; n <= min(M - asize, k / (asize - i)); ++n) {
nextmp[n][k - n] += mp[j][k];
}
aamax = max(aamax, (min(M - asize, k / asize - i)));
aamin = min(aamin, k - min(M - asize, k / (asize - i)));
}
}
}
amin = min(aamin, amin);
amax = max(aamax, amax);
mp = nextmp;
}
Mod ans = 0;
for (int i = 0; i < mp.size(); ++i) ans += mp[i][0];
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using V = vector<T>;
template <class T, class U>
using P = pair<T, U>;
const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;
template <class T>
void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &obj) {
o << "{";
for (auto &x : obj)
o << " {" << x.first << " : " << x.second << "}"
<< ",";
o << " }";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &obj) {
o << "{";
for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i];
o << "}";
return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &obj) {
o << "{" << obj.first << ", " << obj.second << "}";
return o;
}
template <template <class tmp> class T, class U>
ostream &operator<<(ostream &o, const T<U> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
void print(void) { cout << endl; }
template <class Head>
void print(Head &&head) {
cout << head;
print();
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
cout << head << " ";
print(forward<Tail>(tail)...);
}
template <class T>
void chmax(T &a, const T b) {
a = max<T>(a, b);
}
template <class T>
void chmin(T &a, const T b) {
a = min<T>(a, b);
}
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
N = N * N;
V<int> dp(2 * (N + 1) * (S + 1), 0);
dp[0] = 1;
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N + 1; ++j) {
for (int k = 0; k < S + 1; ++k) {
if (j + 1 <= N && k + i + 1 <= S)
(dp[(((i + 1) % 2) * (N + 1) + j + 1) * (S + 1) + (k + i + 1)] +=
dp[((i % 2) * (N + 1) + j) * (S + 1) + k]) %= 100000LL;
else
break;
}
for (int k = 0; k < S + 1; ++k) {
(dp[(((i + 1) % 2) * (N + 1) + j) * (S + 1) + k] +=
dp[((i % 2) * (N + 1) + j) * (S + 1) + k]) %= 100000LL;
}
}
}
cout << dp[((M % 2) * (N + 1) + N) * (S + 1) + S] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
unsigned short dp[162617];
int get(int b) {
return (((dp[b + b / 16] & ((1 << (16 - b % 16)) - 1))) << (b % 16 + 1)) +
(dp[b + b / 16 + 1] >> (15 - b % 16));
}
void set(int b, int v) {
dp[b + b / 16] &= 0xffff - (1 << (16 - b % 16)) + 1;
dp[b + b / 16] |= v >> (b % 16 + 1);
dp[b + b / 16 + 1] &= (1 << (15 - b % 16)) - 1;
dp[b + b / 16 + 1] |= v << (15 - b % 16);
}
int main(void) {
int i, j, k;
int n, m, s;
while (scanf("%d%d%d", &n, &m, &s), n) {
n *= n;
dp[0] = 0;
dp[1] = 0x8000;
for (i = 2; i < 162617; ++i) dp[i] = 0;
for (i = 1; i <= m; ++i) {
for (j = n; j >= 0; --j) {
for (k = s; k >= 0; --k) {
if (j && i <= k) {
int tmp =
(get(j * 3001 + k) + get((j - 1) * 3001 + k - i)) % 100000;
set(j * 3001 + k, tmp);
}
}
}
}
printf("%d\n", get(n * 3001 + s));
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1},
{-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const int kaijou[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
int main() {
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
static int dp[2002][3002] = {};
for (int i = 0; i < 2002; i++) {
for (int j = 0; j < 3002; j++) {
if (j == 0)
dp[i][j] = 1;
else
dp[i][j] = 0;
}
}
int l = 0, r;
for (int i = 1; i <= n * n; i++) {
r = s;
for (int j = i + 1; j <= n * n; j++) {
r -= j;
}
l += i;
for (int j = l; j <= r; j++) {
for (int k = 1; k <= min(m, j); k++) {
dp[k][j] = dp[k - 1][j - k];
dp[k][j] %= 100000;
}
for (int k = min(m, j); k <= m; k++) {
dp[k][j] = 0;
}
dp[0][j] = 0;
}
for (int j = l - i; j < l; j++) {
for (int k = 0; k < m + 1; k++) {
dp[j][k] = 0;
}
}
for (int j = l; j <= r; j++) {
for (int k = 1; k <= m; k++) {
dp[k][j] += dp[k - 1][j];
dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int dp[55][3010];
int n, m, s;
while (1) {
fill((int*)dp, ((int*)dp + 3010), 0);
cin >> n >> m >> s;
const int bin = n * n;
dp[0][0] = 1;
for (int k = 1; k <= m; k++)
for (int i = bin; i > 0; i--) {
for (int j = k; j <= s; j++) {
dp[i][j] = (dp[i - 1][j - k] + dp[i][j]) % 100000;
}
}
cout << dp[bin][s] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[50][3001];
int main() {
int n, m, s;
while (scanf("%d %d %d", &n, &m, &s)) {
if (n == 0 && m == 0 && s == 0) break;
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 1; i <= m; i++) {
for (int j = n * n; j > 0; j--) {
for (int k = i; k <= s; k++) {
dp[j][k] = (dp[j][k] + dp[j - 1][k - i]) % 100000;
}
}
}
printf("%d\n", dp[n * n][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
const int mod = 100000;
int main() {
while (true) {
int n, m, s; cin >> n >> m >> s;
if (n == 0 and m == 0 and s == 0) break;
vector<vector<int> > cur(s+1, vector<int>(m+1));
vector<vector<int> > prv(s+1, vector<int>(m+1));
cur[0][0] = 1;
repeat (i,n*n) {
prv.swap(cur);
repeat (j,s+1) {
cur[j][0] = 0;
repeat (k,min(m,j)) {
cur[j][k+1] = (cur[j-1][k] + prv[j-k-1][k]) % mod;
}
}
}
int ans = accumulate(cur[s].begin(), cur[s].end(), 0ll) % mod;
cout << ans << endl;
}
return 0;
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import static java.util.Arrays.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
static void tr(Object... os) {
System.err.println(deepToString(os));
}
static final int MOD = 100000;
void solve() {
int N = sc.nextInt();
N = N * N;
int M = sc.nextInt();
int S = sc.nextInt();
int[][] dp = new int[N+1][S+1];
dp[0][0] = 1;
for (int m = 1; m <= M; m++) {
for (int n = N-1; n >= 0; n--) {
for (int j = m; j <= S; j++) {
dp[n+1][j] += dp[n][j-m];
if (dp[n+1][j] >= MOD) dp[n+1][j] -= MOD;
}
}
}
out.println(dp[N][S]);
}
public static void main(String[] args) throws Exception {
new Main().run();
}
MyScanner sc = null;
PrintWriter out = null;
public void run() throws Exception {
sc = new MyScanner(System.in);
out = new PrintWriter(System.out);
for (;sc.hasNext();) {
solve();
out.flush();
}
out.close();
}
class MyScanner {
String line;
BufferedReader reader;
StringTokenizer tokenizer;
public MyScanner(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream));
tokenizer = null;
}
public void eat() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
line = reader.readLine();
if (line == null) {
tokenizer = null;
return;
}
tokenizer = new StringTokenizer(line);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
public String next() {
eat();
return tokenizer.nextToken();
}
public String nextLine() {
try {
return reader.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public boolean hasNext() {
eat();
return (tokenizer != null && tokenizer.hasMoreElements());
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public int[] nextIntArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, s;
while (cin >> n >> m >> s && (n || m || s)) {
long long dp[51][3001] = {};
dp[0][0] = 1;
for (int i = 1; i <= m; i++) {
for (int j = n * n; j >= 1; j--) {
for (int k = 1; k <= s; k++) {
if (k - i >= 0) dp[j][k] += dp[j - 1][k - i];
}
}
}
cout << dp[n * n][s] % 100000 << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int M;
map<int, int> mem[50][2001];
int num(int low, int len, int sum) {
if (len == 1) {
if (low < sum && sum <= M) {
return 1;
}
return 0;
}
if (mem[len][low].find(sum) != mem[len][low].end()) {
return mem[len][low][sum];
}
int ret = 0;
for (int i = low + 1; i < M; i++) {
if (i * len + len * (len - 1) / 2 > sum) {
break;
}
ret += num(i, len - 1, sum - i);
ret %= 100000;
}
return mem[len][low][sum] = ret;
}
int main() {
while (1) {
int N, S;
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
cout << num(0, N * N, S) << endl;
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 2001; j++) {
mem[i][j].clear();
}
}
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int mod = 100000;
int N, M, S;
int dp[2009][3009];
int dpsum[2009][3009];
int main() {
while (true) {
scanf("%d%d%d", &N, &M, &S);
if (N == 0 && M == 0 && S == 0) break;
dp[0][0] = 1;
for (int i = 1; i <= N * N; i++) {
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
if (j != 0) {
dpsum[j][k] = dpsum[j - 1][k] + dp[j][k];
if (dpsum[j][k] >= mod) dpsum[j][k] -= mod;
} else {
dpsum[j][k] = dp[j][k];
}
}
}
for (int j = i; j <= M; j++) {
for (int k = i * (i + 1) / 2; k <= S; k++) {
dp[j][k] = 0;
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S - j - 1; k++) {
dp[j + 1][j + k + 1] = dpsum[j][k];
dpsum[j][k] = 0;
}
}
}
int ans = 0;
for (int j = 1; j <= M; j++) {
ans += dp[j][S];
ans %= mod;
}
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)
using namespace std;
typedef unsigned int uint;
typedef long long ll;
int getInt(){
int ret = 0,c;
c = getchar();
while(!isdigit(c)) c = getchar();
while(isdigit(c)){
ret *= 10;
ret += c - '0';
c = getchar();
}
return ret;
}
#define MOD 100000
int n,m,s;
uint memo[2001][3001];
uint prevs[2][3001];
uint *prev, *prev2;
int main(){
while(true){
n = getInt();
m = getInt();
s = getInt();
if(n+m+s == 0) break;
n = n * n;
prev = prevs[0];
prev2 = prevs[1];
REP(i,n){
if(i == 0){
REP(k,m+1) REP(j,s+1) memo[k][j] = 0;
rep(x,1,m+1){
int xx = x * n;
if(xx > s) break;
memo[x][xx] = 1;
}
}else{
memset(prev,0,sizeof(int)*s);
rep(x,1,m+1){
//memcpy(prev2,memo[x],sizeof(int)*s);
rep(y,0,s+1-n+i){
prev2[y+(n-i)] = memo[x][y+(n-i)];
memo[x][y+(n-i)] = (memo[x-1][y] + prev[y]) % MOD;
}
uint *tmp = prev;
prev = prev2;
prev2 = tmp;
}
}
}
int ans = 0;
REP(i,m+1) ans = (ans + memo[i][s]) % MOD;
print(ans);
}
return 0;
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int M = 100000;
int main() {
for (int n, m, sum; scanf("%d%d%d", &n, &m, &sum), n;) {
n *= n;
static int dp[2001][3001], next[2001][3001];
for (int d = 0; d < (m + 1); d++) dp[d][0] = 1;
for (int i = 0; i < (n); i++) {
for (int d = 1; d <= m; d++)
for (int s = 0; s < (sum + 1); s++) {
next[d][s] = next[d - 1][s];
if (s - d >= 0) {
next[d][s] += dp[d - 1][s - d];
if (next[d][s] >= M) next[d][s] -= M;
}
}
memcpy(dp, next, sizeof(dp));
}
printf("%d\n", dp[m][sum]);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<iostream>
using namespace std;
#define NUM 2001
#define SUM 3001
#define DIV 100000
map<pair<short,short>,int >Map[49];
int solve(short pos,short sum,short now,int N,int M,int S){
if ( pos == N*N){
if ( sum == S)return 1;
return 0;
}
map<pair<short,short> ,int >::iterator itr = Map[pos].find(make_pair(now,sum));
if ( itr != Map[pos].end())return (*itr).second;
int ret=0;
for(int i=now+1;i<=M;i++){
if ( i+sum>S)break;
ret = (ret+solve(pos+1,sum+i,i,N,M,S) )%DIV;
}
return Map[pos][make_pair(now,sum)]=ret;
}
main(){
int n,m,s;
while(cin>>n>>m>>s && n){
for(int i=0;i<n*n;i++)Map[i].clear();
cout << solve(0,0,0,n,m,s) << endl;
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[2][3001][50];
int n, m, s;
int main() {
while (cin >> n >> m >> s && (n | m | s)) {
memset(dp, 0, sizeof(dp));
for (int i = 0; i < 2; i++) dp[i][0][n * n] = 1;
for (int i = m; i >= 0; i--) {
for (int j = 0; j <= s; j++) {
for (int k = n * n; k >= 0; k--) {
int cur = (i + 1) % 2;
int nxt = i % 2;
int pos = i;
int lefts = j;
int cnts = k;
int res = 0;
if (k == n * n) {
if (j == 0)
dp[nxt][lefts][cnts] = 1;
else
dp[nxt][lefts][cnts] = 0;
continue;
}
res += dp[cur][lefts][cnts];
if (lefts - pos >= 0) res += dp[cur][lefts - pos][cnts + 1];
dp[nxt][lefts][cnts] = res;
}
}
}
cout << dp[1][s][0] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, s;
int memo[2001][3001][50];
int dfs(int num, int sum, int cou) {
if (cou == n * n + 1) {
if (sum == s)
return 1;
else
return 0;
}
if (memo[num][sum][cou] != -1) return memo[num][sum][cou];
int ret = 0;
for (int i = num; i <= m; i++) {
ret = (ret + dfs(i + 1, sum + i, cou + 1)) % 100000;
}
return memo[num][sum][cou] = ret;
}
int main() {
while (scanf("%d %d %d", &n, &m, &s) && n != 0 && m != 0 && s != 0) {
fill_n(**memo, 2001 * 3001 * 50, -1);
printf("%d\n", dfs(1, 0, 1));
}
return (0);
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
namespace std {
template <>
class hash<tuple<int, int, int>> {
public:
size_t operator()(const tuple<int, int, int>& x) const {
return hash<int>()(get<0>(x)) ^ hash<int>()(get<1>(x)) ^
hash<int>()(get<2>(x));
}
};
} // namespace std
unordered_map<tuple<int, int, int>, int>* memo;
const int MEMO_LIMIT = 1000000;
void memory_init(int size, int max, int sum) {
delete memo;
memo = new unordered_map<tuple<int, int, int>, int>();
}
int memory_set(int size, int max, int sum, int value) {
if (memo->size() < MEMO_LIMIT) {
memo->insert({make_tuple(size, max, sum), value});
}
return value;
}
int memory(int size, int max, int sum) {
auto found = memo->find(make_tuple(size, max, sum));
if (found == memo->end()) return -1;
return found->second;
}
int count(int size, int max, int sum) {
if (memory(size, max, sum) != -1) {
return memory(size, max, sum);
}
int maxMax = sum - (size * (size - 1)) / 2;
if (maxMax > max) maxMax = max;
int ntr = (size * size) - size + 2 * sum;
int dtr = 2 * size;
int maxMin = ntr / dtr;
if ((ntr % dtr) > 0) maxMin++;
if (size == 2) {
return memory_set(size, max, sum, maxMax - maxMin + 1);
}
int ans = 0;
for (int i = maxMin; i <= maxMax; i++) {
ans += count(size - 1, i - 1, sum - i);
ans %= 100000;
}
return memory_set(size, max, sum, ans);
}
int main(int argc, char const* argv[]) {
int n, m, s;
while (true) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
memory_init(n * n, m, s);
cout << count(n * n, m, s) << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int x[2000 + 1][3000 + 1];
int y[2000 + 1][3000 + 1];
int main() {
int n, m, s;
while (true) {
cin >> n >> m >> s;
if ((n == 0 && m == 0) && s == 0) {
break;
}
memset(x, 0, sizeof(x));
memset(y, 0, sizeof(y));
for (int i = 1; i <= m; i++) {
x[i][i] = 1;
}
for (int i = 2; i <= n * n; i++) {
for (int j = i - 1; j <= m; j++) {
for (int k = j; k <= s; k++) {
for (int l = j + 1; l <= m; l++) {
y[l][k + l] += x[j][k];
}
}
}
y[2000][3000] = 0;
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= s; k++) {
x[j][k] = y[j][k] % 100000;
y[j][k] = 0;
}
}
y[0][0] = 0;
}
int sum = 0;
for (int i = 0; i <= m; i++) {
sum += x[i][s];
sum %= 100000;
}
cout << sum << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <iostream>
#include <vector>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
const ll mod = 100000;
int main() {
while (true) {
int n, m, s; cin >> n >> m >> s;
if (n == 0 and m == 0 and s == 0) break;
vector<vector<ll> > dp(vector<vector<ll> >(s+1, vector<ll>(m+1)));
dp[0][0] = 1;
repeat (i,n*n) {
vector<vector<ll> > acc(vector<vector<ll> >(s+1, vector<ll>(m+1)));
repeat (j,s+1) {
repeat (k,m) {
acc[j][k+1] = (acc[j][k] + dp[j][k]) % mod;
}
}
repeat (j,s+1) {
repeat (k,min(m,j)+1) {
dp[j][k] = acc[j-k][k];
}
}
}
ll ans = accumulate(dp[s].begin(), dp[s].end(), 0) % mod;
cout << ans << endl;
}
return 0;
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[2][2000][3000];
signed main() {
int a, b, c;
while (cin >> a >> b >> c, a || b || c) {
a *= a;
c -= a * (a + 1) / 2;
b -= a;
memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;
for (int d = 1; d <= a; d++) {
memset(dp[d & 1], 0, sizeof(dp[d & 1]));
for (int e = 0; e <= b; e++) {
for (int f = 0; f <= c; f++) {
dp[d & 1][e][f] = dp[(d + 1) & 1][e][f];
if (e >= 1 && f >= (a - d + 1)) {
dp[d & 1][e][f] =
(dp[d & 1][e][f] + dp[d & 1][e - 1][f - (a - d + 1)]) % 100000;
}
}
}
}
int sum = 0;
for (int i = 0; i <= b; i++) {
sum += dp[a & 1][i][c] % 100000;
}
cout << sum << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static final int MAX_N = 7;
public static final int MAX_M = 2000;
public static final int MAX_S = 3000;
public static int[][] DP = new int[MAX_S + 1][MAX_M + 1];
public static int[][] next = new int[MAX_S + 1][MAX_M + 1];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
final int N = sc.nextInt();
final int M = sc.nextInt();
final int S = sc.nextInt();
if(N == 0 && M == 0 && S == 0){
break;
}
for(int i = 0; i < S; i++){
for(int j = 0; j < M; j++){
DP[i][j] = next[i][j] = 0;
}
}
DP[S][0] = 1;
for(int iter = 0; iter < N * N; iter++){
for(int cur_S = S; cur_S >= 0; cur_S--){
for(int cur_M = 0; cur_M <= M; cur_M++){
if(DP[cur_S][cur_M] == 0){
continue;
}
for(int next_M = cur_M + 1; next_M <= M; next_M++){
if(cur_S < next_M){
break;
}
next[cur_S - next_M][next_M] += DP[cur_S][cur_M];
next[cur_S - next_M][next_M] %= 100000;
}
}
}
int[][] tmp = next;
next = DP;
DP = tmp;
for(int i = 0; i <= S; i++){
for(int j = 0; j <= M; j++){
next[i][j] = 0;
}
}
}
int sum = 0;
for(int i = 0; i <= M; i++){
sum += DP[0][i];
sum %= 100000;
}
System.out.println(sum);
}
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int i, j, k;
int n, m, s;
int hoge = 0;
while (scanf("%d%d%d", &n, &m, &s), n) {
++hoge;
if (hoge >= 50) exit(1);
}
puts("a");
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
char dp[51 * 3001];
int main(void) {
int i, j, k;
int n, m, s;
while (scanf("%d%d%d", &n, &m, &s), n) {
n *= n;
dp[0] = 1;
for (i = 1; i < 3001 * 51; ++i) dp[i] = 0;
for (i = 1; i <= m; ++i) {
for (j = n; j >= 0; --j) {
for (k = s; k >= 0; --k) {
if (j && i <= k) {
dp[j * 3001 + k] =
(dp[j * 3001 + k] + dp[(j - 1) * 3001 + k - i]) % 100000;
}
}
}
}
printf("%d\n", dp[n * 3001 + s]);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[2][2001][3001];
const int mod = 100000;
int main() {
int n, m, s;
while (cin >> n >> m >> s) {
if (n == 0) break;
n *= n;
dp[0][0][0] = 1;
for (int i = 0; i < n; i++) {
int now = i & 1;
int next = now ^ 1;
for (int j = 0; j <= m; j++)
for (int k = 0; k <= s; k++) dp[next][j][k] = 0;
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= s; k++) {
if (dp[now][j][k] == 0) continue;
(dp[now][j + 1][k] += dp[now][j][k]) %= mod;
if (k + j + 1 <= s)
(dp[next][j + 1][k + j + 1] += dp[now][j][k]) %= mod;
}
}
}
int ans = 0;
for (int i = 0; i <= m; i++) {
ans += dp[n & 1][i][s];
ans %= mod;
}
cout << ans << endl;
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.