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>
int a[50][2001][3001] = {};
int main() { 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, d, e;
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++) {
d = s / (n * n - i + 1);
e = min(m, d);
for (int j = i - 1; j <= e; j++) {
for (int k = j + (i - 2) * (i - 1) / 2; k <= s; k++) {
for (int l = j + 1; l <= e; 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 <bits/stdc++.h>
using namespace std;
constexpr int mod = 100000;
int main() {
int N, M, S;
while (cin >> N >> M >> S, N + M + S) {
vector<vector<long long>> dp(S + 1, vector<long long>(M + 1, 0));
dp[0][0] = 1;
for (int i = 0; i < N * N; i++) {
vector<vector<long long>> nxt(S + 1, vector<long long>(M + 1, 0));
for (int j = 0; j <= S; j++)
for (int k = 1; k <= M; k++) dp[j][k] = (dp[j][k] + dp[j][k - 1]) % mod;
for (int k = 1; k <= M; k++)
for (int j = k; j <= S; j++)
nxt[j][k] = (nxt[j][k] + dp[j - k][k - 1]) % mod;
swap(dp, nxt);
}
long long ret = 0;
for (int i = 1; i <= M; i++) ret += dp[S][i];
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<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);
if(i % 3 == 0){
rep(x,1,m+1){
memcpy(prev2,memo[x],sizeof(int)*s);
REP(y,s+1-n+i){
memo[x][y+(n-i)] = (memo[x-1][y] + prev[y]) % MOD;
}
uint *tmp = prev;
prev = prev2;
prev2 = tmp;
}
}else{
rep(x,1,m+1){
memcpy(prev2,memo[x],sizeof(int)*s);
REP(y,s+1-n+i){
memo[x][y+(n-i)] = (memo[x-1][y] + prev[y]);
}
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 | java | import java.util.Scanner;
//Bingo
public class Main{
void run(){
Scanner sc = new Scanner(System.in);
int MOD = 100000;
int[][][] dp = new int[2][2001][3001];
for(;;){
int N = sc.nextInt(), M = sc.nextInt(), S = sc.nextInt();
if((N|M|S)==0)break;
N*=N;
for(int m=0;m<=M;m++)for(int s=0;s<=S;s++)dp[0][m][s] = 0;
int X = 1;
for(int x=1;x<=N;x++,X=1-X)for(int m=1;m<=M;m++)for(int s=1;s<=S;s++){
dp[X][m][s] = 0;
if(x==1){
if(s<=m)dp[X][m][s]++;
}
else{
dp[X][m][s]+=dp[X][m-1][s];
if(s-m>=0)dp[X][m][s]+=dp[1-X][m-1][s-m];
}
dp[X][m][s]%=MOD;
}
System.out.println(dp[1-X][M][S]);
}
}
public static void main(String[] args) {
new Main().run();
}
} |
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 dp[2][2001][3001];
int main() {
while (cin >> n >> m >> s && n && m && s) {
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++)
if (dp[0][j][k])
for (int lm = j + 1, ls = k + lm; lm <= m && ls <= s;
lm++, ls = k + lm)
dp[1][lm][ls] = (dp[0][j][k] + dp[1][lm][ls]) % MOD;
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= s; k++) {
dp[0][j][k] = dp[1][j][k];
dp[1][j][k] = 0;
}
}
}
int ans = 0;
for (int i = 0; i <= m; i++) ans = (ans + dp[0][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 | cpp | #include <bits/stdc++.h>
using namespace std;
const int surplus = 100000;
int n, m, s, N, ans, ss[50];
int b[50][3001];
bool judge[50][2001][3001];
int dp(int now, int num, int sum) {
if (sum > s) return 0;
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][sum] += dp(now + 1, i + 1, sum + i);
judge[now][i][sum] = 1;
b[now][sum] %= surplus;
}
}
}
return b[now][sum];
}
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 = (0); i < (s + 1); i++) {
ans += b[1][i];
}
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][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;
template <class T>
void max_swap(T& a, const T b) {
a = max(a, b);
}
template <class T>
void min_swap(T& a, const T b) {
a = min(a, b);
}
const double EPS = 1e-10;
int main() {
int n, m, s;
while (scanf("%d%d%d", &n, &m, &s), n | m | s) {
int nn = n * n;
static long long dp[50][3001];
const int mod = 100000;
for (int i = 0; i < nn + 1; ++i)
for (int j = 0; j < s + 1; ++j) dp[i][j] = 0;
dp[0][0] = 1;
for (int i = 1; i <= m; ++i)
for (int j = nn; j > 0; --j)
for (int k = i; k <= s; ++k) (dp[j][k] += dp[j - 1][k - i]) %= mod;
printf("%lld\n", dp[nn][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)
res = 1;
else
res = 0;
} 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>
using namespace std;
int dp[3005][2005][2] = {};
int main() {
int n, m, s;
int i, j, k, l;
while (1) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
for (i = 0; i < s + 1; i++)
for (j = 0; j < m + 1; j++)
if (i == j)
dp[i][i][1] = 1;
else
dp[i][j][1] = 0;
for (k = 1; k < n * n + 1; k++) {
for (i = 0; i < s + 1; i++)
for (j = 0; j < m + 1; j++) dp[i][j][(k + 1) % 2] = 0;
for (i = 1; i < s + 1; i++) {
for (j = 1; j < m + 1; j++)
if (dp[i][j][k % 2]) {
for (l = j + 1; i + l <= s + 1; l++)
if (l <= m) {
dp[i + l][l][(k + 1) % 2] += dp[i][j][k % 2];
}
}
}
}
long long int sum = 0;
for (j = 0; j < m + 1; j++) sum = (sum + dp[s][j][(n * n) % 2]) % 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 | 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 = i; k <= min(m, j); k++) {
dp[k][j] = dp[k - 1][j - k];
if (dp[k][j] >= 100000) 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 = min(m, j); 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;
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][101][3001];
long long cal(int n, int mx, int sum) {
long long res = 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 N, M, S;
vector<int> mem[50][2001];
int num(int n, int m, int s) {
if (n == 1) {
if (s <= m) {
return 1;
}
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 = 1; i < m; i++) {
if (s - i * n < (n - 1) * n / 2) {
break;
}
ret += num(n - 1, m - i, s - i * n);
}
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;
const int INF = 1001001001;
int N, M, S;
const int mod = 100000;
int main() {
while (1) {
scanf("%d %d %d", &N, &M, &S);
if (N == 0 && M == 0 && S == 0) break;
int dp[2002][3002];
for (int i = 0; i < M + 1; i++) {
for (int j = 0; j < S + 1; j++) {
if (j == 0) {
dp[i][j] = (i == 0 ? 1 : 0);
}
if (j - i > -1) {
dp[i][j] += dp[j - i][j - i] % mod;
}
if (i != 0) dp[i][j] += dp[i - 1][j] % mod;
dp[i][j] %= mod;
}
}
int ans = 0;
for (int i = 0; i < M + 1; i++) ans += dp[i][S] % mod;
printf("%d\n", ans % mod);
}
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;
cin >> n >> m >> s;
n = n * n;
for (int i = 0; i <= m; i++) {
for (int j = 0; j <= s; j++) dp[0][i][j] = 0;
}
dp[0][0][0] = 1;
for (int i = 0; i < n; i++) {
int cur = i & 1, nxt = 1 - cur;
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= s; k++) dp[nxt][j][k] = 0;
}
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= s; k++) {
if (j < m) {
(dp[cur][j + 1][k] += dp[cur][j][k]) %= mod;
if (k + j + 1 <= s)
(dp[nxt][j + 1][k + j + 1] += dp[cur][j][k]) %= mod;
}
}
}
}
for (int i = 0; i < m; i++) (dp[n & 1][i + 1][s] += dp[n & 1][i][s]) %= mod;
cout << dp[n & 1][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 N, M, S;
int dp[3000 + 1][2000 + 1];
int dp2[3000 + 1][2000 + 1];
int main() {
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
memset(dp, 0, sizeof(dp));
memset(dp2, 0, sizeof(dp2));
dp[0][0] = 1;
for (int i = 0; i < N * N; i++) {
for (int j = 0; j <= S; j++) {
for (int k = 1; k <= M; k++) {
dp2[j][k] = dp2[j][k - 1] + dp[j][k];
dp2[j][k] %= 100 * 1000;
}
}
for (int j = 0; j <= S; j++) {
for (int k = 1; k <= M; k++) {
if (j - k >= 0) {
dp[j][k] = dp2[j - k][k - 1];
} else {
dp[j][k] = 0;
}
}
}
}
cout << dp[S][M] << 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];
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 = 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 % 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 | UNKNOWN | @memory = {}
def count(size, max, sum)
return @memory[[size, max, sum]] if @memory[[size, max, sum]]
return @memory[[size, max, sum]] = 1 if size == 1
max_max = [sum - size * (size - 1) / 2, max].min
n = (size ** 2) - size + 2 * sum
d = 2 * size
max_min = n / d
max_min += 1 if n % d > 0
# return @memory[[size, max, sum]] = 1 if max_max == max_min
if size == 2
return @memory[[size, max, sum]] = max_max - max_min + 1
end
ans = 0
# puts "size: #{size}, max_max: #{max_max} max_min: #{max_min}"
(max_min..max_max).each do |max_size|
ans += count(size - 1, max_size - 1, sum - max_size)
ans %= 100000
end
@memory[[size, max, sum]] = ans
end
STDIN.each_line do |line|
n, m, s = line.split(" ").map(&:to_i)
break if n == 0 && m == 0 && s == 0
puts count(n ** 2, m, 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;
static const double EPS = 1e-10;
static const double PI = acos(-1.0);
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const long long LL_INF = 1ll << 60;
static const int dx[] = {-1, 0, 1, 0, 1, -1, 1, -1};
static const int dy[] = {0, -1, 0, 1, 1, 1, -1, -1};
static short n, m, s;
static short dp[50][2001][3001];
void input() { cin >> n >> m >> s; }
int dfs(int now, int num, int many) {
if (now == n * n) {
return !many;
}
if (many < num * (n * n - now) || m == num) {
return 0;
}
if (dp[now][num][many] >= 0) {
return dp[now][num][many];
}
short res = 0;
for (int i = num + 1; i <= m; i++) {
res += dfs(now + 1, i, many - i);
res %= 100000;
}
return dp[now][num][many] = res;
}
void solve() {
memset((dp), -1, sizeof(dp));
cout << dfs(0, 0, s) << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
input();
solve();
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[2][2001][2001];
int T[2001][2001];
int main() {
cin >> N >> M >> S;
for (int i = 0; i <= min(M, S); i++) dp[0][i][i] = 1;
N *= N;
S -= N * (N + 1) / 2;
M = min(M - N, S);
for (int i = 0; i < N - 1; i++) {
int _ = i % 2;
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
dp[_ ^ 1][j][k] = 0;
T[j][k] = 0;
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
if (j + k <= S) {
T[j][j + k] = (T[j][j + k] + dp[_][j][k]) % 100000;
}
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
if (j > 0 && k > 0) T[j][k] = (T[j][k] + T[j - 1][k - 1]) % 100000;
dp[_ ^ 1][j][k] = (dp[_ ^ 1][j][k] + T[j][k]) % 100000;
}
}
}
int m = 0;
for (int i = 0; i <= M; i++) m = (m + dp[(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 main() {
int n, m, s;
int i, j, k, l;
while (1) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
static int dp[3005][2005][50] = {};
for (i = 1; i <= m; i++) dp[i][i][1] = 1;
for (i = 0; i < s + 1; i++) {
for (j = 0; j < m + 1; j++)
for (k = 0; k < n * n + 1; k++)
if (dp[i][j][k])
for (l = j + 1; i + l <= s + 1; l++)
if (l <= m) {
dp[i + l][l][k + 1] += dp[i][j][k];
}
}
long long int sum = 0;
for (j = 0; j < m + 1; j++) sum = (sum + dp[s][j][n * n]) % 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 | cpp | using namespace std;
#define SUM 3001
#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 | 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;
for(int _=0;_<n*n;_++){
next[] = 0;
for(int i=0;i<m;i++){
for(int j=0;j<s;j++){
for(int k=1;k*(n*n-_)<=(s-j) && k<=m-i;k++){
next[(i+k)*(s+1)+j+k*(n*n-_)] = (next[(i+k)*(s+1)+j+k*(n*n-_)]+now[i*(s+1)+j])%100000;
}
}
}
swap(now,next);
}
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 | cpp | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 7;
const int MAX_S = 3000;
int dp[MAX_N * MAX_N + 1][MAX_S + 1];
int main() {
int N, M, S;
while (cin >> N >> M >> S, N) {
memset(dp, 0, sizeof dp);
N *= N;
dp[0][0] = 1;
for (int i = 1; i <= M; ++i) {
for (int j = N; j >= 1; --j) {
for (int k = S; k >= i; --k) {
dp[j][k] += dp[j - 1][k - i];
dp[j][k] %= 100000;
}
}
}
cout << dp[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;
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); }
};
int dp[2][2020][3030] = {};
int main(void) {
int N, M, S;
while (cin >> N >> M >> S && N && M && S) {
memset(dp, 0, sizeof dp);
for (int i = (1); i < (M + 1); i++) {
dp[1][i][i] = 1;
}
for (int i = (2); i < (N * N + 1); i++) {
memset(dp[i % 2], 0, sizeof dp[i % 2]);
for (int j = (i); j < (M + 1); j++) {
for (int k = ((i * (i + 1)) / 2); k < (S + 1); k++) {
for (int s = 0; s < (min(k + 1, j)); s++) {
if (k >= j) {
dp[i % 2][j][k] += dp[(i + 1) % 2][s][k - j];
dp[i % 2][j][k] = dp[i % 2][j][k] % 100000;
}
}
}
}
}
ll res = 0;
for (int i = 0; i < (M + 1); i++) {
res += dp[(N * N) % 2][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 | UNKNOWN | import std.algorithm;
import core.stdc.stdio;
import std.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[(n*n+1)*(s+1)];
int[] next = new int[(n*n+1)*(s+1)];
now[0] = 1;
for(int i=1;i<=m;i++){
next[] = 0;
for(int j=0;j<=n*n;j++){
for(int k=0;k<=s;k++){
if(k+i<=s && j < n*n){
next[(j+1)*(s+1)+k+i] = (next[(j+1)*(s+1)+k+i]+now[j*(s+1)+k])%100000;
}
next[j*(s+1)+k] = (next[j*(s+1)+k]+now[j*(s+1)+k])%100000;
}
}
swap(now,next);
}
printf("%d\n",now[(n*n)*(s+1)+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() {
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 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 <bits/stdc++.h>
constexpr int MOD = (int)1e5;
constexpr int MAX_N = 7, MAX_M = 2000, MAX_S = 3000;
int n, m, s;
int dp[MAX_N * MAX_N + 1][MAX_M + 1][MAX_S + 1];
int main() {
while (1) {
std::cin >> n >> m >> s;
if (n + m + s == 0) break;
std::memset(dp, 0, sizeof(dp));
for (int i = 1; i <= std::min(m, s); ++i) dp[1][i][i] = 1;
for (int i = 2; i <= n * n; ++i) {
for (int j = 1; j <= std::min(m, s); ++j) {
for (int k = j; k <= s; ++k) {
for (int l = 1; l < j; ++l) {
dp[i][j][k] += dp[i - 1][l][k - j];
dp[i][j][k] %= MOD;
}
}
}
}
int ans = 0;
for (int i = 1; i <= std::min(m, s); ++i)
ans = (ans + dp[n * n][i][s]) % MOD;
std::cout << ans << std::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[3005][2005][2];
int main() {
int n, m, s;
int i, j, k, l;
while (1) {
scanf("%d %d %d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
for (i = 0; i < s + 1; i++)
for (j = 0; j < m + 1; j++)
if (i == j) dp[i][i][1] = 1;
for (k = 1; k < n * n; k++) {
for (i = 1; i < s + 1; i++) {
for (j = 1; j < m; j++)
if (dp[i][j][k % 2]) {
for (l = j + 1; i + l <= s + 1; l++)
if (l <= m) {
dp[i + l][l][(k + 1) % 2] += dp[i][j][k % 2];
}
dp[i][j][k % 2] = 0;
}
}
}
long long int sum = 0;
for (j = 0; j < m + 1; j++) sum = (sum + dp[s][j][(n * n) % 2]) % 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 | cpp | #include <bits/stdc++.h>
int 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;
}
}
}
}
int ans = 0;
for (i = n; i <= m; i++) ans = (ans + dp[(n * n - 1) % 2][i][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 | 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);
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)]);
}
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;
int main() {
int n, m, s;
int i, j, k, l;
while (1) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
static int dp[3005][2005][2] = {};
for (i = 0; i < s + 1; i++)
for (j = 0; j < m + 1; j++)
if (i == j)
dp[i][i][1] = 1;
else
dp[i][j][1] = 0;
for (k = 1; k < n * n + 1; k++) {
for (i = 0; i < s + 1; i++)
for (j = 0; j < m + 1; j++) dp[i][j][(k + 1) % 2] = 0;
for (i = 1; i < s + 1; i++) {
for (j = 1; j < m + 1; j++)
if (dp[i][j][k % 2]) {
for (l = j + 1; i + l <= s + 1; l++)
if (l <= m) {
dp[i + l][l][(k + 1) % 2] += dp[i][j][k % 2];
}
}
}
}
long long int sum = 0;
for (j = 0; j < m + 1; j++) sum = (sum + dp[s][j][(n * n) % 2]) % 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 | 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() {
while (true) {
scanf("%d%d%d", &N, &M, &S);
if (N == 0 && M == 0 && S == 0) break;
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 | cpp | #include <bits/stdc++.h>
int dp[3001][50];
int main() {
int n, m, s;
while (scanf("%d%d%d", &n, &m, &s)) {
if (!n && !m && !s) 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 = 1; k <= s; k++) {
if (k >= i) dp[k][j] = (dp[k][j] + dp[k - i][j - 1]) % 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>
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;
scanf("%d %d %d", &n, &m, &s);
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("%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;
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 <= 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 = 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;
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 = (1); j < (m + 1); j++)
for (int k = (j); k < (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);
}
long long 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 main() {
int n, m, s;
int i, j, k, l;
while (1) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
int dp[3005][2005][2] = {};
for (i = 0; i < s + 1; i++)
for (j = 0; j < m + 1; j++)
if (i == j)
dp[i][i][1] = 1;
else
dp[i][j][1] = 0;
for (k = 1; k < n * n + 1; k++) {
for (i = 0; i < s + 1; i++)
for (j = 0; j < m + 1; j++) dp[i][j][(k + 1) % 2] = 0;
for (i = 1; i < s + 1; i++) {
for (j = 1; j < m + 1; j++)
if (dp[i][j][k % 2]) {
for (l = j + 1; i + l <= s + 1; l++)
if (l <= m) {
dp[i + l][l][(k + 1) % 2] += dp[i][j][k % 2];
}
}
}
}
long long int sum = 0;
for (j = 0; j < m + 1; j++) sum = (sum + dp[s][j][(n * n) % 2]) % 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 | 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++) {
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;
const int surplus = 100000;
int n, m, s, sum, N, ans;
int b[2][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 = (1); j < (3001); j++) {
for (int k = (1); k < (2001); k++) {
b[1][j][k] = b[2][j][k];
b[2][j][k] = 0;
}
}
for (int j = (i); j < (3001); j++) {
for (int k = (i - 1); k < (3001); k++) {
if (b[i][j][j - k]) break;
if (j > k && j - k <= 2000) {
for (int l = (i - 1); l < (2001); l++) {
if (j - k > l) {
b[2][j][j - k] += b[1][k][l];
}
}
b[2][j][j - k] %= surplus;
}
}
}
}
while (cin >> n >> m >> s) {
if (!n && !m && !s) return 0;
ans = 0;
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[49][2999][1999]{};
int main() { 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;
int*** memo;
void memory_init(int size, int max, int sum) {
memo = new int**[size];
for (int i = 0; i < size; i++) {
memo[i] = new int*[max];
for (int j = 0; j < max; j++) {
memo[i][j] = new int[sum];
for (int k = 0; k < sum; k++) {
memo[i][j][k] = -1;
}
}
}
}
int memory_set(int size, int max, int sum, int value) {
memo[size - 1][max - 1][sum - 1] = value;
return value;
}
int memory(int size, int max, int sum) {
return memo[size - 1][max - 1][sum - 1];
}
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;
const int mod = 100000;
int main() {
int n, m, s;
int dp[50][2001];
while (cin >> 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 - 1; j >= 0; --j) {
for (int k = 0; k <= s - i; ++k) {
dp[j + 1][k + i] += dp[j][k];
dp[j + 1][k + i] %= mod;
}
}
}
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 | java | import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
//Bingo
public class Main{
@SuppressWarnings("unchecked")
void run(){
Scanner sc = new Scanner(System.in);
int MOD = 100000;
Set<int[]>[] input = new Set[50];
for(int i=0;i<50;i++)input[i] = new HashSet<int[]>();
int Q = 0;
for(;;Q++){
int N = sc.nextInt(), M = sc.nextInt(), S = sc.nextInt();
if((N|M|S)==0)break;
input[N*N].add(new int[]{Q, M, S});
}
int[] res = new int[Q];
int[][][] dp = new int[2][2001][3001];
int X = 1;
for(int x=1;x<50;x++,X=1-X){
for(int m=1;m<=2000;m++)for(int s=1;s<=3000;s++){
dp[X][m][s] = 0;
if(x==1){
if(s<=m)dp[X][m][s]++;
}
else{
dp[X][m][s]+=dp[X][m-1][s];
if(s-m>=0)dp[X][m][s]+=dp[1-X][m-1][s-m];
}
if(MOD<=dp[X][m][s])dp[X][m][s]-=MOD;
}
for(int[]a:input[x]){
res[a[0]] = dp[X][a[1]][a[2]];
}
}
for(int r:res)System.out.println(r);
}
public static void main(String[] args) {
new Main().run();
}
} |
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() {
int i;
int n, m, s;
unsigned int dp[2][2001][3001];
unsigned int sum;
scanf("%d %d %d", &n, &m, &s);
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
for (int n, m, s; cin >> n >> m >> s, n | m | s;) {
m = min(m, s);
vector<vector<vector<int> > > dp(
3, vector<vector<int> >(m + 1, vector<int>(s + 1)));
for (int i = int(1); i < int(m + 1); i++)
for (int j = int(1); j < int(i + 1); j++) dp[1][i][j] = 1;
for (int i = int(2); i < int(n * n + 1); i++) {
for (int j = int(1); j < int(m + 1); j++) {
fill((dp[i % 3][j]).begin(), (dp[i % 3][j]).end(), 0);
for (int k = int(1); k < int(s + 1); k++) {
dp[i % 3][j][k] = dp[i % 3][j - 1][k];
if (j <= k) dp[i % 3][j][k] += dp[(i - 1) % 3][j - 1][k - j];
dp[i % 3][j][k] %= 100000;
}
}
}
cout << dp[n * n % 3][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 dp[51][2001][3001];
int main() {
int n, m, s;
while (cin >> n >> m >> s && n) {
memset(dp, 0, sizeof(dp));
n = n * n;
for (int i = 1; i <= m; i++) dp[0][i][i] = 1;
for (int i = 1; i < n; i++) {
for (int y = 0; y <= s; y++) {
int tmp = 0;
for (int x = 1; x <= m && x + y <= s; x++) {
dp[i][x][y + x] += tmp;
dp[i][x][y + x] %= 100000;
tmp += dp[i - 1][x][y];
}
}
}
int ans = 0;
for (int i = 1; i <= m; i++) ans = (ans + dp[n - 1][i][s]) % 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;
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) {
ll N, M, S;
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
N = N * N;
V<V<ll>> dp(N + 1, V<ll>(S + 1, 0));
dp[0][0] = 1;
for (int i = 0; i < M; ++i) {
V<V<ll>> tmp(N + 1, V<ll>(S + 1, 0));
for (int j = 0; j < N + 1; ++j) {
for (int k = 0; k < S + 1; ++k) {
if (j + 1 <= N && k + i + 1 <= S)
(tmp[j + 1][k + (i + 1)] += dp[j][k]) %= 100000LL;
else
break;
}
for (int k = 0; k < S + 1; ++k) {
(tmp[j][k] += dp[j][k]) %= 100000LL;
}
}
dp = tmp;
}
cout << dp[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 mod = 100000;
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 * n;
static int dp[2][3001][2001] = {0};
int(*cur)[2001] = dp[0];
int(*next)[2001] = dp[1];
for (int i = 1; i <= min(m, s); ++i) cur[i][i] = 1;
for (int i = 1; i < n; ++i) {
for (int sum = 1; sum <= s; ++sum) {
int lim = min(m, sum);
for (int x = 1; x <= lim; ++x) {
next[sum][x] = next[sum - 1][x - 1];
if (sum >= x) next[sum][x] += cur[sum - x][x - 1];
next[sum][x] %= mod;
}
}
swap(next, cur);
}
int ans = 0;
for (int x = 1; x <= m; ++x) {
ans += cur[s][x];
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>
using namespace std;
const int surplus = 100000;
int n, m, s, N, ans;
int b[50][3001];
bool judge[50][2001][3001];
int dp(int now, int num, int sum) {
if (sum > s) return 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][sum] += dp(now + 1, i + 1, sum + i);
judge[now][i][sum] = 1;
b[now][sum] %= surplus;
}
}
}
return b[now][sum];
}
int main() {
while (cin >> n >> m >> s) {
if (!n && !m && !s) return 0;
ans = 0;
N = n * n;
for (int i = (1); i < (39); i++) dp(1, i, 0);
for (int i = (0); i < (s + 1); i++) {
ans += b[1][i];
}
ans %= surplus;
cout << ans << endl;
for (int i = (1); i < (50); i++) {
for (int j = (1); j < (2001); j++) {
for (int k = (0); k < (3001); k++) {
b[i][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<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>
using namespace std;
#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
unsigned long long 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;
REP(i,0,N*N){
REP(j,0,S){
if(i==0 && j==0) B[0][i][j]=1;
else B[0][i][j]=0;
}
}
REP(n,0,N*N){
REP(k,0,M-1){
REP(s,0,S){
if(s-(k+1)>=0 && n-1>=0)
B[k+1][n][s]=B[k][n-1][s-(k+1)]+B[k][n][s];
else
B[k+1][n][s]=B[k][n][s];
}
}
}
cout << B[M][N*N][S]%100000 << endl;
REP(k,0,M) REP(n,0,N*N) REP(s,0,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 | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[50][3001];
const int MOD = 100000;
int main() {
while (true) {
int n, m, s;
cin >> n >> m >> s;
if (n == 0) break;
n = n * n;
for (int i = 0; i < int(50); ++i)
for (int j = 0; j < int(3001); ++j) dp[i][j] = 0;
dp[0][0] = 1;
for (int i = 0; i < int(m + 1); ++i)
if (i > 0)
for (int j = n; j > 0; --j)
for (int k = j; k <= s; ++k) {
dp[j][k] += dp[j - 1][k - i];
dp[j][k] %= MOD;
}
cout << dp[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<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);
if(i % 8 == 0){
rep(x,1,m+1){
memcpy(prev2,memo[x],sizeof(int)*s);
REP(y,s+1-n+i){
memo[x][y+(n-i)] = (memo[x-1][y] + prev[y]) % MOD;
}
uint *tmp = prev;
prev = prev2;
prev2 = tmp;
}
}else{
rep(x,1,m+1){
memcpy(prev2,memo[x],sizeof(int)*s);
REP(y,s+1-n+i){
memo[x][y+(n-i)] = (memo[x-1][y] + prev[y]);
}
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;
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) {
ll N, M, S;
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
N = N * N;
V<V<V<ll>>> dp(M + 1, V<V<ll>>(N + 1, V<ll>(S + 1, 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) {
if (i + 1 <= M && j + 1 <= N && k + i + 1 <= S)
(dp[i + 1][j + 1][k + (i + 1)] += dp[i][j][k]);
if (i + 1 <= M) (dp[i + 1][j][k] += dp[i][j][k]);
}
}
}
cout << dp[M][N][S] % 100000LL << 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][2002][3001];
int main() {
for (int i = 0; i <= 2001; i++) {
for (int j = 0; j <= 3000; j++) {
DP[0][i][j] = 0;
}
DP[1][i][i] = 1;
}
DP[1][0][0] = 0;
for (int i = 2; i < 50; i++) {
for (int j = 1; j <= 2000; j++) {
for (int k = j; k <= 3000; k++) {
DP[i][j][k] = DP[i][j - 1][k - 1] + DP[i - 1][j - 1][k - j];
DP[i][j][k] %= 100000;
}
}
}
int n, m, s;
while (true) {
cin >> n >> m >> s;
if (n == 0) {
break;
}
n *= n;
int ans = 0;
for (int i = 0; i <= m; i++) {
ans += DP[n][i][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>
using namespace std;
const int MAXN = 7, MAXM = 2010, MAXS = 3000;
int n, m, s;
unsigned int dp[MAXN * MAXN + 2][MAXM + 10][MAXS + 10], UB = 100000;
int main() {
memset(dp, 0, sizeof(dp));
for (int i_m = 0; i_m < MAXM + 1; i_m++) dp[0][i_m][0] = 1;
for (int i_n = 0; i_n < MAXN * MAXN + 1; i_n++)
for (int i_m = 0; i_m < MAXM + 1; i_m++)
for (int i_s = 0; i_s < MAXS + 1; i_s++)
if (i_s - (i_m + 1) > -1)
dp[i_n + 1][i_m + 1][i_s] =
(dp[i_n + 1][i_m][i_s] + dp[i_n][i_m][i_s - (i_m + 1)]) % UB;
else
dp[i_n + 1][i_m + 1][i_s] = dp[i_n + 1][i_m][i_s];
while (cin >> n >> m >> s && n) cout << dp[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;
template <class T>
void debug(T begin, T end) {
for (T i = begin; i != end; ++i) cerr << *i << " ";
cerr << endl;
}
inline bool valid(int x, int y, int W, int H) {
return (x >= 0 && y >= 0 && x < W && y < H);
}
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 100000;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M, S;
map<pair<int, int>, int> memo[50];
int dfs(int k, int last, int sum) {
if (memo[k].count(pair<int, int>(last, sum)))
return memo[k][pair<int, int>(last, sum)];
int& res = memo[k][pair<int, int>(last, sum)];
if (k == N - 1) {
int next = S - sum;
if (next > last && next <= M)
return res = 1;
else
return res = 0;
}
res = 0;
for (int a = last + 1; a <= M; a++) {
int n = N - k;
if (sum + n * (2 * a + n - 1) / 2 > S) break;
res += dfs(k + 1, a, sum + a);
res %= MOD;
}
return res;
}
int main() {
while (cin >> N >> M >> S && N) {
N *= N;
for (int i = (0); i < (int)(50); ++i) memo[i].clear();
cout << dfs(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;
const int mod = 100000;
int n, m, s;
int dp[50][2010][3100];
int dfs(int i = 0, int pre = 0, int sum = s) {
if (sum < 0) return 0;
if (pre > m) return 0;
if (i == n * n) {
return sum == 0;
}
int &ret = dp[i][pre][sum];
if (ret != -1) return ret;
ret = 0;
for (int j = pre + 1; j <= m; j++) {
ret += dfs(i + 1, j, sum - j);
ret %= mod;
}
return ret;
}
signed main() {
while (cin >> n >> m >> s, n) {
memset(dp, -1, sizeof(dp));
cout << dfs() << 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];
const int mod = 100000;
int n, m, s;
int main() {
while (cin >> n >> m >> s && (n | m | s)) {
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)
res = 1;
else
res = 0;
} 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[0][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 | 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 c = a + (a >> 4), d = b + (b >> 4);
int tmp =
(((((dp[c] & ((1 << (16 - (a & 15))) - 1))) << ((a & 15) + 1)) +
(dp[c + 1] >> (15 - (a & 15)))) +
((dp[d] & ((1 << (16 - (b & 15))) - 1)) << (((b & 15) + 1))) +
(dp[d + 1] >> (15 - (b & 15)))) %
100000;
dp[c] = (dp[c] & (0xffff - (1 << (16 - (a & 15))) + 1)) |
(tmp >> ((a & 15) + 1));
dp[c + 1] = (dp[c + 1] & ((1 << (15 - (a & 15))) - 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;
int N, M, S;
int dp[50][2001][3001];
int main() {
cin >> N >> M >> S;
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>
constexpr int MOD = (int)1e5;
constexpr int MAX_M = 2000, MAX_S = 3000;
int n, m, s;
int dp[2][MAX_M + 1][MAX_S + 1];
int main() {
while (1) {
std::cin >> n >> m >> s;
if (n + m + s == 0) break;
std::memset(dp, 0, sizeof(dp));
for (int i = 1; i <= std::min(m, s); ++i) dp[1][i][i] = 1;
for (int i = 2; i <= n * n; ++i) {
for (int j = 1; j <= std::min(m, s); ++j) {
for (int k = j; k <= s; ++k) {
for (int l = 1; l < j; ++l) {
dp[i % 2][j][k] += dp[(i - 1) % 2][l][k - j];
dp[i % 2][j][k] %= MOD;
}
}
}
std::memset(dp[(i - 1) % 2], 0, sizeof(dp[(i - 1) % 2]));
}
int ans = 0;
for (int i = 1; i <= std::min(m, s); ++i)
ans = (ans + dp[(n * n) % 2][i][s]) % MOD;
std::cout << ans << std::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 double eps = 1e-8;
const double INF = 1e12;
double dot(complex<double> a, complex<double> b) {
return a.real() * b.real() + a.imag() * b.imag();
}
double cross(complex<double> a, complex<double> b) {
return a.real() * b.imag() - a.imag() * b.real();
}
bool is_orthogonal(complex<double> a1, complex<double> a2, complex<double> b1,
complex<double> b2) {
return (abs((dot(a1 - a2, b1 - b2)) - (0.0)) < (1e-10));
}
bool is_parallel(complex<double> a1, complex<double> a2, complex<double> b1,
complex<double> b2) {
return (abs((cross(a1 - a2, b1 - b2)) - (0.0)) < (1e-10));
}
bool is_point_on_line(complex<double> a, complex<double> b, complex<double> c) {
return (abs((cross(b - a, c - a)) - (0.0)) < (1e-10));
}
bool is_point_on_linesegment3(complex<double> a, complex<double> b,
complex<double> c) {
return (abs(a - c) + abs(c - b) < abs(a - b) + (1e-10));
}
double distance_l_p(complex<double> a, complex<double> b, complex<double> c) {
return abs(cross(b - a, c - a)) / abs(b - a);
}
double distance_ls_p(complex<double> a, complex<double> b, complex<double> c) {
if (dot(b - a, c - a) < (1e-10)) return abs(c - a);
if (dot(a - b, c - b) < (1e-10)) return abs(c - b);
return abs(cross(b - a, c - a)) / abs(b - a);
}
int dp[56][2001][3001];
int func(int n, int m, int s) {
if (dp[n][m][s] != -1) return dp[n][m][s];
if (s <= 0) return 0;
if (n == 1) {
if (m <= 0 || m < s)
return 0;
else
return 1;
}
if (s <= 0) return 0;
int res = 0;
for (int i = 1; i < m; i++) {
res += func(n - 1, m - i, s - m + i - 1);
res %= 100000;
}
return dp[n][m][s] = res;
}
int main() {
int n, m, s;
while (1) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
for (int i = 0; i < 56; i++)
for (int j = 0; j < 2001; j++)
for (int k = 0; k < 3001; k++) dp[i][j][k] = -1;
cout << func(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 | UNKNOWN | #include <bits/stdc++.h>
int M;
int *done;
int *memo;
int num(int i, int N, int S) {
if (done[i * 50 * 3100 + N * 3100 + S]) {
return (memo[i * 50 * 3100 + N * 3100 + S]);
}
printf("%d %d %d\n", i, N, S);
if (N == 0) {
return (S == 0);
}
if (S < 0) {
return (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);
return (memo[i * 50 * 3100 + N * 3100 + S] % 100000);
}
int main(void) {
int N, S;
done = (int *)malloc(2100 * 50 * 3100 + 50 * 3100 + 3100);
memo = (int *)malloc(2100 * 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;
static const double EPS = 1e-10;
static const double PI = acos(-1.0);
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const long long LL_INF = 1ll << 60;
static const int dx[] = {-1, 0, 1, 0, 1, -1, 1, -1};
static const int dy[] = {0, -1, 0, 1, 1, 1, -1, -1};
static short n, m, s;
static short dp[50][2001][3001];
void input() { cin >> n >> m >> s; }
int dfs(int now, int num, int many) {
if (now == n * n) {
return !many;
}
if (many < num * (n * n - now) || m == num) {
return 0;
}
if (dp[now][num][many] >= 0) {
return dp[now][num][many];
}
int res = 0;
for (int i = num + 1; i <= m; i++) {
res += dfs(now + 1, i, many - i);
res %= 100000;
}
return dp[now][num][many] = res;
}
void solve() {
memset((dp), -1, sizeof(dp));
cout << dfs(0, 0, s) << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
input();
solve();
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 | python2 | mod=100000
while 1:
n,m,s=map(int,raw_input().split())
if n==m==s==0:break
dp=[[[0]*(s+1) for _ in xrange(m+2)] for _ in xrange(n**2+1)]
for j in xrange(1,m+1):
dp[0][j][0]=1
for i in xrange(n**2):
for j in xrange(1,m+1):
for k in xrange(s+1):
if j>k:
dp[i+1][j+1][k]=dp[i+1][j][k]
continue
dp[i+1][j+1][k]+=(dp[i+1][j][k])%mod
dp[i+1][j+1][k]+=(dp[i][j][k-j])%mod
print(dp[n**2][m+1][s]%mod) |
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);
if (i == 0) {
for (int k = 0; k < (int)(m + 1); k++)
for (int j = 0; j < (int)(second + 1); j++) memo[dp][k][j] = 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++) {
int *dpp = memo[dp][x];
int *dpp2 = memo[dp][x - 1];
int *dpp3 = memo[dp2][x - 1];
for (int y = (n - i); y < (int)(second + 1); y++) {
dpp[y] = (dpp2[y - (n - i)] + dpp3[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 | cpp | #include <bits/stdc++.h>
using namespace std;
int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
int dp[2001][3001][75];
int main() { printf("aaa\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>
#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);
}
}
}
}
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;
template <class T1, class T2>
inline bool minimize(T1 &a, T2 b) {
return b < a && (a = b, 1);
}
template <class T1, class T2>
inline bool maximize(T1 &a, T2 b) {
return a < b && (a = b, 1);
}
int const inf = 1 << 29;
int dp[55][3030];
int main() {
for (int N, M, S; cin >> N >> M >> S && (N | M | S);) {
for (int i = 0; i < (int)55; i++)
for (int j = 0; j < (int)3030; j++) dp[i][j] = 0;
dp[0][0] = 1;
for (int add = 1; add < (int)M + 1; add++) {
for (int currIndex = N * N; currIndex >= 1; currIndex--) {
for (int currSum = add; currSum <= S; currSum++) {
dp[currIndex][currSum] += dp[currIndex - 1][currSum - add];
}
}
}
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 N, M, S;
int dp[3000 + 1][2000 + 1];
int dp2[3000 + 1][2000 + 1];
vector<int> ns[8];
vector<int> ms, ss;
vector<int> ret;
int main() {
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) break;
ns[N].push_back((int)ms.size());
ms.push_back(M);
ss.push_back(S);
ret.push_back(0);
}
int n = 1;
for (int i = 0; i <= 2000; i++) {
dp2[0][i] = 1;
}
for (int a = 1; a <= 49; a++) {
for (int j = 0; j <= 3000; j++) {
int v = min(2000, j);
for (int k = 1; k <= v; k++) {
dp[j][k] = dp2[j - k][k - 1];
}
}
for (int j = 0; j <= 3000; j++) {
dp2[j][0] = dp[j][0];
for (int k = 1; k <= 2000; k++) {
dp2[j][k] = dp2[j][k - 1] + dp[j][k];
if (dp2[j][k] >= 100 * 1000) {
dp2[j][k] -= 100 * 1000;
}
}
}
if (a == n * n) {
for (int i = 0; i < ns[n].size(); i++) {
int j = ns[n][i];
ret[j] = dp2[ss[j]][ms[j]];
}
n++;
}
}
for (int i = 0; i < ret.size(); i++) {
cout << ret[i] << 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 | using namespace std;
#define NUM 2001
#define SUM 3001
#define DIV 100000
int table[49][NUM][SUM]={0};
int solve(int pos,int sum,int now,int N,int M,int S){
if ( pos == N*N){
if ( sum == S)return 1;
return 0;
}
if ( table[pos][now][sum] !=-1)return table[pos][now][sum];
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 table[pos][now][sum]=ret;
}
main(){
int n,m,s;
while(cin>>n>>m>>s && n){
for(int i=0;i<n*n;i++)
for(int j=0;j<=s;j++)
for(int k=0;k<=m;k++)table[i][k][j]= -1;
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][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 j = 0; j <= m; j++)
for (int k = 0; k <= s; k++) dp[0][j][k] = 0;
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;
}
}
}
cout << dp[n & 1][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>
int dp[3001][2001];
int main() {
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0) return 0;
memset(dp, '\0', sizeof(dp));
for (int k = 0; k < s; k++)
for (int i = 0; i < m; i++)
if (i >= k) dp[k][i] = 1;
int i, j, k;
for (i = 1; i < n * n; i++) {
for (k = s - 1; k >= 0; k--) {
for (j = 0; j <= m - 1; j++) {
if (j == 0)
dp[k][j] = 0;
else if (k >= j + 1)
dp[k][j] = dp[k - j - 1][j - 1] + dp[k][j - 1];
else
dp[k][j] = dp[k][j - 1];
dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[s - 1][m - 1]);
}
}
|
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;
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;
}
#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 % 10 == 9){
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)]);
}
swap(prev,prev2);
}
}
}
}
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 | UNKNOWN | @memory = {}
def count(size, max, sum)
return @memory[[size, max, sum]] if @memory[[size, max, sum]]
return @memory[[size, max, sum]] = 1 if size == 1
max_max = [sum - size * (size - 1) / 2, max].min
n = (size ** 2) - size + 2 * sum
d = 2 * size
max_min = n / d
max_min += 1 if n % d > 0
# return @memory[[size, max, sum]] = 1 if max_max == max_min
if size == 2
return @memory[[size, max, sum]] = max_max - max_min + 1
end
ans = 0
# puts "size: #{size}, max_max: #{max_max} max_min: #{max_min}"
(max_min..max_max).each do |max_size|
# max_size: 譛?、ァ隕∫エ??隕∫エ?焚
ans += count(size - 1, max_size - 1, sum - max_size)
ans %= 100000
end
@memory[[size, max, sum]] = ans
end
STDIN.each_line do |line|
n, m, s = line.split(" ").map(&:to_i)
break if n == 0 && m == 0 && s == 0
puts count(n ** 2, m, 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 = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
int n, m, s;
int dp[50][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s), n) {
for (int i = 0; i < n * n + 1; i++)
for (int j = 0; j < s + 1; j++) dp[i][j] = 0;
dp[0][0] = 1;
m = min(m, s);
for (int i = 0; i < m; i++) {
for (int j = n * n; j > 0; j--)
for (int k = s; k > n * n - j; k--)
dp[j][k] =
(dp[j - 1][k - (n * n - j + 1)] + dp[j][k - (n * n - j + 1)]) %
100000;
}
printf("%d\n", dp[n * 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 | UNKNOWN | #include <bits/stdc++.h>
int memo_func[2][3001][2001];
int N, M, S;
void set_func(int sum, int max);
void dbg_print();
void reflesh();
int main() {
int i, j, k;
int ans;
while (1) {
scanf("%d %d %d\n", &N, &M, &S);
if (!N && !M && !S) break;
for (i = 0; i < 2; i++) {
for (j = 1; j <= M; j++) {
for (k = 1; k <= S; k++) {
memo_func[i][k][j] = 0;
if (i == 0 && k == j) memo_func[i][k][j] = 1;
}
}
}
for (i = 1; i < N * N; i++) {
for (j = 1; j <= M; j++) {
for (k = 1; k <= S; k++) {
set_func(k, j);
}
}
reflesh();
}
ans = 0;
for (i = 0; i <= M; i++) {
ans += memo_func[0][S][i];
ans %= 100000;
}
printf("%d\n", ans);
}
return 0;
}
void set_func(int sum, int max) {
int i, j;
for (i = max + 1; (sum + i <= S) && (i <= M); i++) {
memo_func[1][sum + i][i] += memo_func[0][sum][max];
memo_func[1][sum + i][i] %= 100000;
}
return;
}
void reflesh() {
int i, j;
for (i = 0; i <= S; i++) {
for (j = 0; j <= M; j++) {
memo_func[0][i][j] = memo_func[1][i][j];
memo_func[1][i][j] = 0;
}
}
return;
}
void dbg_print() {
int i, j, k;
for (i = 0; i <= N * N; i++) {
for (j = 0; j <= S; j++) {
printf("masu=%d Sum=%d ", i, j);
for (k = 0; k <= M; k++) {
printf("%d ", memo_func[i][j][k]);
}
puts("");
}
puts("");
}
}
|
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 dp[55][2005][3005];
int main() {
int h, i, j, k, n, m, s, ans;
while (1) {
scanf("%d%d%d", &n, &m, &s);
if (n + m + s == 0) break;
memset(dp, 0, sizeof(dp));
ans = 0;
n = n * n;
for (i = 1; i <= m; i++) dp[0][i][i] = 1;
for (i = 1; i < n; i++) {
for (j = 1; j <= m; j++) {
for (k = j; k <= s; k++) {
for (h = 1; h < j; h++) {
dp[i][j][k] += dp[i - 1][h][k - j];
}
dp[i][j][k] %= 100000;
}
}
}
for (j = 1; j <= m; j++) {
ans += dp[n - 1][j][s];
ans = ans % 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 | cpp | #include <bits/stdc++.h>
using namespace std;
long long mod = 100000;
long long N, M, S;
int dp[2001][50][3001];
long long solve(long long num, long long cnt, long long sum) {
if (dp[num][cnt][sum] != -1) return dp[num][cnt][sum];
if (cnt == 0) return (sum == 0 ? 1 : 0);
long long res = 0;
for (int i = num; i <= M; i++)
res = (res + solve(i + 1, cnt - 1, sum - i)) % mod;
dp[num][cnt][sum] = res;
return res;
}
void init() {
for (int i = 0; i < 2001; i++)
for (int j = 0; j < 50; j++)
for (int k = 0; k < 3001; k++) dp[i][j][k] = -1;
}
int main() {
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) break;
init();
cout << solve(1, 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 | java | import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
static int MOD = 100000;
public static void main(String[] args) {
while (true) {
int N = sc.nextInt();
N *= N;
int M = sc.nextInt();
int S = sc.nextInt();
if (N == 0) break;
S -= N * (N + 1) / 2;
M -= N;
int turn = 1;
int[][][] dp = new int[2][S + 1][M + 1];
dp[0][S][0] = 1;
for (int i = 0; i < N; ++i) {
int maxM = M / (N - i);
for (int[] a : dp[turn]) {
for (int j = 0; j <= maxM; ++j) {
a[j] = 0;
}
}
int maxK = Math.min(M, S / (N - i));
for (int j = 0; j <= S; ++j) {
for (int k = 0; k <= maxK; ++k) {
if (dp[1 - turn][j][k] == 0) continue;
for (int l = 0; k + l <= M; ++l) {
int ns = j - l * (N - i);
if (ns < 0) break;
dp[turn][ns][k + l] += dp[1 - turn][j][k];
if (dp[turn][ns][k + l] >= MOD) dp[turn][ns][k + l] -= MOD;
}
}
}
turn = 1 - turn;
}
int ans = 0;
for (int i = 0; i <= M; ++i) {
ans += dp[1 - turn][0][i];
}
System.out.println(ans % MOD);
}
}
} |
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>
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 / 16] & ((1 << (16 - a % 16)) - 1)))
<< (a % 16 + 1)) +
(dp[a + a / 16 + 1] >> (15 - a % 16)) +
(((dp[b + b / 16] & ((1 << (16 - b % 16)) - 1)))
<< (b % 16 + 1)) +
(dp[b + b / 16 + 1] >> (15 - b % 16))) %
100000;
dp[a + a / 16] &= 0xffff - (1 << (16 - a % 16)) + 1;
dp[a + a / 16] |= tmp >> (a % 16 + 1);
dp[a + a / 16 + 1] &= (1 << (15 - a % 16)) - 1;
dp[a + a / 16 + 1] |= tmp << (15 - a % 16);
}
}
}
}
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;
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 = 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 res = 0;
if (k == n * n) {
if (j == 0)
res = 1;
else
res = 0;
} 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[0][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<map>
#include<vector>
using namespace std;
int N, M, S;
int cnt;
typedef pair<int,int> elem;
void comb(int n, int k){
int *p;
bool loop = false;
p = new int[k];
for(int i = 0; i < k; i++){
p[i] = i;
}
do{
int sum = 0;
int diff2cnt = 0;
int diffMax = 0;
loop = false;
for(int i = 0; i < k; i++){
sum += p[i] + 1;
}
if( sum == S ){
cnt++;
/*for(int i = 0; i < k; i++){
cout << p[i] + 1 << ' ';
}*/
for(int i = 1; i < k; i++){
if(p[i] - p[i - 1] >= 2){
diff2cnt++;
diffMax = max( diffMax , p[i] - p[i - 1] );
}
}
//cout << diff2cnt << endl;
if( diff2cnt == 1 && diffMax == 2 ){
return ;
}
//cout << '\n';
}
for(int pk = k - 1; pk >= 0; pk--){
p[pk]++;
if( p[pk] <= n - (k - pk) ){
for(int j = pk + 1; j < k; j++){
p[j] = p[j - 1] + 1;
}
pk++;
loop = true;
break;
}
}
}while(loop);
}
int main(void){
while( 1 ){
cin >> N >> M >> S;
if( N == 0 && M == 0 && S == 0 ){
break;
}
cnt = 0;
comb(M, N*N);
cout << cnt << '\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>
#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) {
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 n, m, s, ans;
int dp[50][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s) && n && m && s) {
for (int i = 1; i <= m; i++) dp[1][i][i] = 1;
for (int i = 2; i <= n * n; i++) {
for (int j = 1; j <= m; j++) {
for (int k = 1; k < j; k++) {
for (int l = 1; l <= s; l++) {
if (j + l > s) {
break;
} else {
dp[i][j][j + l] += dp[i - 1][k][l];
dp[i][j][j + l] %= 100000;
}
memset(dp[i - 1], 0, sizeof dp[i - 1]);
}
}
}
}
for (int i = 1; i <= m; i++) {
ans += dp[n * n][i][s];
ans %= 100000;
}
printf("%d\n", ans);
memset(dp, 0, sizeof dp);
ans = 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 mod = 100000;
int N, M, S;
int dp[2009][3009];
int dpsum[2009][3009];
int dp1[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];
}
if (j + k + 1 <= S) {
dp1[j + 1][j + k + 1] = dpsum[j][k];
}
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
dp[j][k] = dp1[j][k];
dp1[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 | python3 | def allocate(remains, limit_h, limit_w):
global m
if not remains:
return 1
if limit_w == 1:
return int(remains <= limit_h)
return sum(allocate(remains - i, i, limit_w - 1) for i in
range(min(limit_h, remains, m - limit_w), (remains - 1) // limit_w, -1))
while True:
n, m, s = map(int, input().split())
if not n:
break
remains = s - sum(range(1, n ** 2 + 1))
print(allocate(remains, remains, n ** 2)) |
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 psum = (lb - 1) * (n - idx) + (n - idx) * (n - idx + 1) / 2;
if (psum > sum) return memo[idx][lb][sum] = 0;
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 <bits/stdc++.h>
using namespace std;
int dp[50][2001][3001];
int func(int n, int m, int s) {
if (s < 0) return 0;
if (dp[n][m][s] != -1) return dp[n][m][s];
if (n == 0) {
if (s == 0)
return 1;
else
return 0;
}
int res = 0;
for (int i = 1; i < m + 1; i++) {
res += func(n - 1, i - 1, s - i);
res %= 100000;
}
return dp[n][m][s] = res % 100000;
}
int main() {
int n, m, s;
while (cin >> 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] = -1;
cout << func(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 | UNKNOWN | MOD = 100000
until (n, m, s = gets.split.map(&:to_i)).all?(&:zero?)
dp = Array.new(n * n + 1){Array.new(s + 1, 0)}
dp[0][0] = 1
(1 .. m).each do |i|
(1 .. n * n).to_a.reverse.each do |j|
(i .. s).each do |k|
dp[j][k] += dp[j - 1][k - i]
dp[j][k] %= MOD
end
end
end
p dp.last.last
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;
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<V<int>>> dp(2, V<V<int>>(N + 1, V<int>(S + 1, 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) {
if (i + 1 <= M && j + 1 <= N && k + i + 1 <= S)
(dp[(i + 1) % 2][j + 1][k + (i + 1)] += dp[i % 2][j][k]) %=
100000LL;
else
break;
}
for (int k = 0; k < S + 1; ++k) {
(dp[(i + 1) % 2][j][k] += dp[i % 2][j][k]) %= 100000LL;
}
}
}
cout << dp[M % 2][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;
template <class T>
void debug(T begin, T end) {
for (T i = begin; i != end; ++i) cerr << *i << " ";
cerr << endl;
}
inline bool valid(int x, int y, int W, int H) {
return (x >= 0 && y >= 0 && x < W && y < H);
}
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 100000;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N, M, S;
map<pair<int, int>, int> memo[50];
int dfs(int k, int last, int sum) {
if (memo[k].count(pair<int, int>(last, sum)))
return memo[k][pair<int, int>(last, sum)];
int& res = memo[k][pair<int, int>(last, sum)];
if (k == N - 1) {
int next = S - sum;
if (next > last && next <= M)
return res = 1;
else
return res = 0;
}
res = 0;
int n = N - k;
int first = max(S - ((n - 1) * (2 * M - (n - 2)) / 2 + sum), last + 1);
for (int a = first; a <= M - n + 1; a++) {
if (sum + n * (2 * a + n - 1) / 2 > S) break;
res += dfs(k + 1, a, sum + a);
res %= MOD;
}
return res;
}
int main() {
while (cin >> N >> M >> S && N) {
N *= N;
for (int i = (0); i < (int)(50); ++i) memo[i].clear();
cout << dfs(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 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 = (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 * 3 / 2 + 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 | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int dp[50][3001];
int i, j, k;
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (i = 1; i <= m; i++) {
for (j = n * n; j >= 1; j--) {
for (k = i; 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]);
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--) {
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;
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;
for (int j = l; j <= s; 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 = 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];
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;
const int mod = 100000;
int dp[2][2048][3005];
int N, M, S;
int main() {
while (scanf("%d%d%d", &N, &M, &S) && N || M || S) {
memset(dp, 0, sizeof dp);
dp[0][0][0] = 1;
int cur = 0, tar = 1;
for (int i = 0; i < N * N; i++) {
cur = i & 1, tar = cur ^ 1;
memset(dp[tar], 0, sizeof dp[tar]);
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
for (int l = j + 1; l <= M; l++) {
if (k + l > S) continue;
dp[tar][l][k + l] = (dp[tar][l][k + l] + dp[cur][j][k]) % mod;
}
}
}
}
int res = 0;
for (int i = 0; i <= M; i++) res = (res + dp[tar][i][S]) % mod;
printf("%d\n", res);
}
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][2005][2];
int main() {
int n, m, s;
int i, j, k, l;
while (1) {
scanf("%d %d %d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
for (i = 0; i < s + 1; i++)
for (j = 0; j < m + 1; j++)
if (i == j)
dp[i][i][1] = 1;
else
dp[i][j][1] = 0;
for (k = 1; k < n * n; k++) {
for (i = 1; i < s + 1; i++) {
for (j = 1; j < m; j++)
if (dp[i][j][k % 2]) {
for (l = j + 1; i + l <= s + 1; l++)
if (l <= m) {
dp[i + l][l][(k + 1) % 2] += dp[i][j][k % 2];
}
dp[i][j][k % 2] = 0;
}
}
}
long long int sum = 0;
for (j = 0; j < m + 1; j++) sum = (sum + dp[s][j][(n * n) % 2]) % 100000;
cout << sum << endl;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.