Search is not available for this dataset
name
stringlengths 2
88
| description
stringlengths 31
8.62k
| public_tests
dict | private_tests
dict | solution_type
stringclasses 2
values | programming_language
stringclasses 5
values | solution
stringlengths 1
983k
|
---|---|---|---|---|---|---|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18 + 9;
const long long int Mod = 1e9 + 7;
inline long long int replac(string s) {
double ans = 0;
for (long long int i = 0; i < s.length(); i++) {
ans += (s[i] - '0') * pow(10, s.length() - i - 1);
}
return (long long int)ans;
}
inline string numstr(long long int m) {
string s = "";
while (m > 0) {
char c;
long long int a = m / 10;
if (a > 0)
a = m % (a * 10);
else
a = m;
c = (char)('0' + a);
s += c;
m /= 10;
}
string st = "";
for (long long int i = s.size() - 1; i >= 0; i--) {
st += s[i];
}
return st;
}
long long int dp[50][3003];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
long long int n, m, s;
long long int mod = 100000;
while (1) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
for (long long int i = 0; i < 50; i++) {
for (long long int j = 0; j < 3003; j++) {
dp[i][j] = 0;
}
}
dp[0][0] = 1;
for (long long int i = 1; i < m + 1; i++) {
for (long long int j = n * n; j >= 0; j--) {
for (long long int k = i; k < s + 1; k++) {
(dp[j][k] += dp[j - 1][k - i]) %= mod;
}
}
}
cout << dp[n * n][s] % 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[2][2000][3000];
signed main() {
int a, b, c;
while (cin >> a >> b >> c, a || b || c) {
a *= a;
c -= a * (a + 1) / 2;
b -= a;
memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;
for (int d = 1; d <= a; d++) {
memset(dp[d & 1], 0, sizeof(dp[d & 1]));
for (int e = 0; e <= b; e++) {
for (int f = 0; f <= c; f++) {
dp[d & 1][e][f] = dp[(d + 1) & 1][e][f];
if (e >= 1 && f >= (a - d + 1)) {
dp[d & 1][e][f] =
(dp[d & 1][e][f] + dp[d & 1][e - 1][f - (a - d + 1)]) % 100000;
}
}
}
}
int sum = 0;
for (int i = 0; i <= b; i++) {
sum = (sum + dp[a & 1][i][c]) % 100000;
}
cout << sum << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int surplus = 100000;
int N, ans;
int b[2][2001][3001];
int main() {
int n, m, s;
while (cin >> n >> m >> s) {
if (!n && !m && !s) return 0;
ans = 0;
N = n * n;
for (int i = (1); i < (m + 1); i++) b[0][i][i] = 1;
for (int i = (2); i < (N + 1); i++) {
for (int j = (1); j < (m); j++) {
for (int k = (1); k < (s); k++) {
b[1][j + 1][k + 1] = b[1][j][k] + b[0][j][k - j];
b[1][j + 1][k + 1] %= surplus;
if (i == N && k + 1 == s) {
ans += b[1][j + 1][k + 1];
}
}
}
for (int j = (1); j < (m); j++) {
for (int k = (1); k < (s); k++) {
b[0][j][k] = b[1][j][k];
b[1][j][k] = 0;
if (i == N) b[0][j][k] = 0;
}
}
}
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 | java | import java.util.Scanner;
//Bingo
public class Main{
void run(){
Scanner sc = new Scanner(System.in);
int MOD = 100000;
// long T = System.currentTimeMillis();
for(;;){
int N = sc.nextInt(), M = sc.nextInt(), S = sc.nextInt();
if((N|M|S)==0)break;
N*=N;
int[][][] dp = new int[2][2001][3001];
// 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];
}
if(MOD<=dp[X][m][s])dp[X][m][s]-=MOD;
}
System.out.println(dp[1-X][M][S]);
}
// System.out.println(System.currentTimeMillis()-T);
}
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;
int mod = 100000;
int N, M, S;
int dp[2009][3009];
int dpsum[2009][3009];
int main() {
while (true) {
scanf("%d%d%d", &N, &M, &S);
if (N == 0 && M == 0 && S == 0) break;
dp[0][0] = 1;
for (int i = 1; i <= N * N; i++) {
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
if (j != 0) {
dpsum[j][k] = dpsum[j - 1][k] + dp[j][k];
if (dpsum[j][k] >= mod) dpsum[j][k] -= mod;
} else {
dpsum[j][k] = dp[j][k];
}
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
dp[j][k] = 0;
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S - j - 1; k++) {
dp[j + 1][j + k + 1] = dpsum[j][k];
dpsum[j][k] = 0;
}
}
}
int ans = 0;
for (int j = 1; j <= M; j++) {
ans += dp[j][S];
ans %= mod;
}
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)
using namespace std;
typedef unsigned int uint;
typedef long long ll;
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)]);
}
int *tmp = prev;
prev = prev2;
prev2 = tmp;
}
}
}
}
int ans = 0;
REP(i,m+1) ans = (ans + memo[i][s]) % MOD;
print(ans);
}
return 0;
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[3005][50] = {};
int n, m, s;
int main() {
while (1) {
scanf("%d %d %d", &n, &m, &s);
if (!n) break;
for (int i = 0; i <= s; i++) {
dp[i][0] = 1;
}
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n * n; j++) {
for (int k = s; k >= i; k--) {
dp[k][j] += dp[k - i][j - 1];
dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[s][n * n]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int dp[51 * 3001];
int main(void) {
char n, j;
short m, s, i, k;
while (scanf("%d%hd%hd", &n, &m, &s), n) {
n *= n;
memset(dp, 0, sizeof(dp));
dp[0] = 1;
for (i = 1; i <= m; ++i) {
for (j = n; j >= 0; --j) {
for (k = s; k >= 0; --k) {
if (j && i <= k) {
dp[j * 3001 + k] =
(dp[j * 3001 + k] + dp[(j - 1) * 3001 + k - i]) % 100000;
}
}
}
}
printf("%d\n", dp[n * 3001 + s]);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[2][55][3005];
int n, m, s;
int main(void) {
while (1) {
cin >> n >> m >> s;
if (!n && !m && !s) break;
n *= n;
dp[0][0][0] = 1;
for (int i = 1; i <= m; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; k <= s; k++) {
dp[i % 2][j][k] = dp[(i + 1) % 2][j][k];
if (k - i >= 0 && j > 0)
dp[i % 2][j][k] =
(dp[(i + 1) % 2][j - 1][k - i] + dp[i % 2][j][k]) % 100000;
}
}
}
cout << dp[m % 2][n][s] << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int mod = 100000;
int dp[2][2048][3005];
int N, M, S;
int main() {
scanf("%d%d%d", &N, &M, &S);
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;
#define int long long
const int mod = 100000;
int n, m, s;
int dp[50][2010][3010];
int dfs(int i = 0, int pre = 0, int sum = 0)
{
if (i == n * n) return sum == s;
if (pre > m) return 0;
int &ret = dp[i][pre][sum];
if (ret != -1) return ret;
int cnt = 0;
for (int j = pre + 1; j <= m; j++){
if (sum + j > s) break;
cnt += dfs(i + 1, j, sum + j);
cnt %= mod;
}
return ret = cnt;
}
signed main()
{
while (cin >> n >> m >> s, n){
for (int i = 0; i < n * n; i++){
for (int j = 0; j < m; j++){
for (int k = 0; k < 3010; k++){
dp[i][j][k] = -1;
}
}
}
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<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 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 <cstdio>
using namespace std;
int n, m, s;
int dp[49][2001][3001];
int main(){
while(1){
scanf("%d %d %d", &n, &m, &s);
if(n == 0) break;
dp = {{{}}};
for(int i=1; i<s+1; i++){
dp[0][i][i] = 1;
}
for(int i=1; i<n*n; i++){
for(int j=1; j<s+1; j++){
for(int k=1; k<m+1; k++){
for(int l=1; l<k; l++){
dp[i][j][k] += dp[i-1][j-k][l];
dp[i][j][k] %= 100000;
}
}
}
}
for(int i=1; i<m+1; i++){
ans += dp[n*n-1][s][i];
ans %= 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 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 | java | import java.util.Scanner;
//Bingo
public class Main{
void run(){
Scanner sc = new Scanner(System.in);
int MOD = 100000;
sc.nextInt();
// long T = System.currentTimeMillis();
for(;;){
int N = sc.nextInt(), M = sc.nextInt(), S = sc.nextInt();
if((N|M|S)==0)break;
N*=N;
int[][][] dp = new int[2][2001][3001];
// 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];
}
if(MOD<=dp[X][m][s])dp[X][m][s]-=MOD;
}
System.out.println(dp[1-X][M][S]);
}
// System.out.println(System.currentTimeMillis()-T);
}
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 | 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++){
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] += now[j*(s+1)+k];
if(next[(j+1)*(s+1)+k+i] >= 100000)
next[(j+1)*(s+1)+k+i] -= 100000;
}
next[j*(s+1)+k] += now[j*(s+1)+k];
if(next[j*(s+1)+k] >= 100000)
next[j*(s+1)+k] -= 100000;
now[j*(s+1)+k] = 0;
}
}
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 n, m, s;
int dp[55][2002][3003];
int solve(int i, int l, int v) {
if (i == n * n) return v == s ? 1 : 0;
if (dp[i][l][v] >= 0) return dp[i][l][v];
int res = 0;
for (int j = l; j <= m; j++) {
if (v + j > s) continue;
res += solve(i + 1, j + 1, v + j);
}
return dp[i][l][v] = res % 100000;
}
int main(void) {
while (cin >> n >> m >> s && n) {
memset(dp, -1, sizeof(dp));
cout << solve(0, 1, 0) << 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][2002][3001];
int main() {
int n, m, s;
while (true) {
cin >> n >> m >> s;
if (n == 0) {
break;
}
n *= n;
for (int i = 0; i <= 2000; 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 <= n; i++) {
for (int j = 1; j <= 2000; j++) {
for (int k = j; k <= 3000; k++) {
DP[i % 2][j][k] =
DP[i % 2][j - 1][k - 1] + DP[(i - 1) % 2][j - 1][k - j];
DP[i % 2][j][k] %= 100000;
}
}
}
int ans = 0;
for (int i = 0; i <= m; i++) {
ans += DP[n % 2][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;
int N, M, S;
int dp[50][3001][2001];
const int MOD = 100000;
int main() {
cin >> N >> M >> S;
for (int i = 1; i <= S; i++) {
dp[1][i][i] = 1;
}
for (int i = 1; i < N * N; i++) {
for (int j = 1; j <= S; j++) {
for (int k = 1; k <= j; k++) {
for (int l = k + 1; l <= M; l++) {
if (j + l <= S) {
dp[i + 1][j + l][l] += dp[i][j][k];
dp[i + 1][j + l][l] %= MOD;
}
}
}
}
}
int ans = 0;
for (int i = 1; i <= M; i++) {
ans += dp[N * N][S][i];
}
cout << ans % 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;
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;
s -= (0 + (n - 1)) * n / 2;
m = min(m, s);
static int dp[3001][2001] = {0};
memset(dp[0], 0, 3001 * 2001 * sizeof(int));
for (int i = 1; i <= m; ++i) dp[i][i] = 1;
for (int i = 1; i < n; ++i) {
for (int x = 1; x <= m - i; ++x) {
for (int sum = s; sum > 0; --sum) {
dp[sum][x] = 0;
if (1 < sum && 1 < x) dp[sum][x] += dp[sum - 1][x - 1];
if (0 < sum - x) dp[sum][x] += dp[sum - x][x];
dp[sum][x] %= mod;
}
}
}
int ans = 0;
for (int i = 1; i <= m - (n - 1); ++i) {
ans += dp[s][i];
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;
int mod = 100000;
int N, M, S;
int dp[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 (dp[j][k] == 0) continue;
for (int l = j + 1; l <= M; l++) {
if (k + l <= S) {
dp1[l][k + l] += dp[j][k];
dp1[l][k + l] %= mod;
}
}
}
}
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 | cpp | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(){
int n,m,s;
while(cin>>n>>m>>s){
if(n==0&&m==0&&s==0)break;
int dp[2][2300][3300];
rep(i,2)rep(j,2300)rep(k,3300)dp[i][j][k]=0;
dp[0][0][0] = 1;
for(int i=1;i<=n*n;i++){
for(int j=0;j<2300;j++)
for(int k=0;k<3300;k++)
dp[i%2][j][k] = 0;
for(int j=1;j<=m;j++){
for(int k=1;k<=s;k++){
if(k-j>=0){
dp[i%2][j][k] += dp[i%2][j-1][k-1] + dp[(i-1)%2][j-1][k-j];
dp[i%2][j][k] %= 100000;
}
}
}
}
ll ans = 0;
for(int i=0;i<=m;i++){
ans+=dp[(n*n)%2][i][s];
ans%=100000;
}
cout<<ans<<endl;
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <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 && i <= 1) res = 1;
} else {
res += dp[cur][j][k];
if (j - i >= 0) res += dp[cur][j - i][k + 1];
}
dp[nxt][j][k] = res % mod;
}
}
}
cout << dp[1][s][0] % mod << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
constexpr int mod = 100000;
int main() {
int N, M, S;
while (1) {
scanf("%d%d%d", &N, &M, &S);
if (N + M + S == 0) break;
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;
printf("%d\n", (int)ret);
}
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 M, S, N;
vector<int> mem[50][2001];
int num(int low, int len, int sum) {
if (len == 1) {
if (low < sum && sum <= M) {
return 1;
}
return 0;
}
if (sum < mem[len][low].size() && mem[len][low][sum] != 0) {
return mem[len][low][sum] - 1;
}
int ret = 0;
for (int i = low + 1; i <= M - len + 1; i++) {
if (i * len + len * (len - 1) / 2 > sum) {
break;
}
ret += num(i, len - 1, sum - i);
ret %= 100000;
}
if (mem[len][low].size() <= sum) {
mem[len][low].resize(min((sum + 1) * 3 / 2, S + 1));
}
mem[len][low][sum] = ret + 1;
return ret;
}
int main() {
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
cout << num(0, N * N, S) << endl;
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 2001; j++) {
mem[i][j].clear();
}
}
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, s, ans;
int dp[2][3010][4010];
int main() {
while (cin >> n >> m >> s && n) {
memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;
for (int i = 0; i < n * n; ++i) {
for (int j = 0; j < m; ++j)
for (int k = j; k < s; ++k)
dp[1][j + 1][k + 1] = (dp[1][j][k] + dp[0][j][k - j]) % 100000;
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;
}
}
}
ans = 0;
for (int i = 0; i <= m; ++i) {
ans += dp[0][i][s];
ans %= 100000;
}
cout << ans << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
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 | 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;
}
} |
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++) {
for (int k = 0; k <= 2000; k++) {
if (j - k >= 0 && k > 0) {
dp[j][k] = dp2[j - k][k - 1];
} else {
dp[j][k] = 0;
}
}
}
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];
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 | #include <bits/stdc++.h>
int dp[50][3001];
int main() {
int n, m, s;
while (scanf("%d %d %d", &n, &m, &s), n) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 1; i <= m; i++)
for (int j = n * n; j >= 1; j--)
for (int k = 1; k <= s; k++) {
dp[j][k] += dp[j - 1][k - i];
if (dp[j][k] >= 100000) dp[j][k] -= 100000;
}
printf("%d\n", dp[n * n][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int memo[50][3001][2001];
int a;
int f(int rem, int m, int sum) {
int i, j;
int ans;
if (rem != 0 && sum <= 0) {
return (0);
}
if (rem == 0) {
if (sum == 0) {
return (1);
} else {
return (0);
}
}
ans = 0;
for (i = m; (i * (i + 1)) / 2 >= sum; i--) {
if (0 <= sum - i && memo[rem - 1][i - 1][sum - i] != -1) {
ans += memo[rem - 1][i - 1][sum - i];
} else if (sum - i >= 0) {
ans += f(rem - 1, i - 1, sum - i);
}
if (ans >= 100000) {
ans -= 100000;
}
}
return (memo[rem][m][sum] = ans);
}
int main(void) {
int n, m, s;
while (1) {
scanf("%d%d%d", &n, &m, &s);
if (n == 0) {
break;
}
memset(memo, -1, sizeof(memo));
printf("%d\n", f(n * n, m, 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 | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static final int MAX_N = 7;
public static final int MAX_D = MAX_N * MAX_N;
public static final int MAX_M = 2000;
public static final int MAX_S = 3000;
public static ArrayList<ArrayList<HashMap<Integer, Integer>>> memo = new ArrayList<ArrayList<HashMap<Integer,Integer>>>(MAX_D);
//public static int[][][] memo = new int[MAX_D + 1][MAX_S + 1][MAX_M + 1];
public static int DFS(int deep, int max_d, int S, int M, final int max_M){
//System.out.println(deep + " " + max_d + " " + S + " " + M + " " + max_M);
if(/*memo[deep][S][M] >= 0*/ memo.get(deep).get(S).containsKey(M)){
//System.out.println(S + " " + M + " " + memo[deep][S][M]);
return /*memo[deep][S][M]*/ memo.get(deep).get(S).get(M);
} else if(deep == max_d){
//System.out.println(S + " " + M);
/*return memo[deep][S][M] = (S == 0 ? 1 : 0);*/ memo.get(deep).get(S).put(M, S == 0 ? 1 : 0);
return S == 0 ? 1 : 0;
}
/* cut */
final int diff = (max_d - deep);
if(S < diff * M){
//System.out.println(diff + " " + S + " " + M);
memo.get(deep).get(S).put(M, 0);
return 0;
//return memo[deep][S][M] = 0;
}
int sum = 0;
for(int next_M = M + 1; next_M <= max_M; next_M++){
if(S < next_M){
break;
}
sum += DFS(deep + 1, max_d, S - next_M, next_M, max_M);
sum %= 100000;
}
//System.out.println(deep + " " + S + " " + M + " " + sum);
memo.get(deep).get(S).put(M, sum);
return sum;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i = 0; i <= MAX_D; i++){
memo.add(new ArrayList<HashMap<Integer,Integer>>(MAX_S));
for(int j = 0; j <= MAX_S; j++){
memo.get(i).add(new HashMap<Integer, Integer>());
}
}
while (true) {
final int N = sc.nextInt();
final int M = sc.nextInt();
final int S = sc.nextInt();
if (N == 0 && M == 0 && S == 0) {
break;
}
for(int i = 0; i <= N * N; i++){
for(int j = 0; j <= S; j++){
memo.get(i).get(j).clear();
}
}
System.out.println(DFS(0, N * N, S, 0, M));
}
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, s;
int dp[2][2001][3001];
int pv[2001][3001];
int main() {
while (cin >> n >> m >> s && n) {
n *= n;
m = min(m, s);
memset(dp[0], 0, sizeof(dp[0]));
for (int i = 1; i <= m; i++) dp[0][i][i] = 1;
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= s; k++) {
pv[j][k] = (j ? pv[j - 1][k] : 0) + dp[0][j][k];
}
}
for (int i = 1; i < n; i++) {
memset(dp[i & 1], 0, sizeof(dp[i & 1]));
for (int j = 1; j <= m; j++) {
for (int k = j; k <= s; k++) {
(dp[i & 1][j][k] += pv[j - 1][k - j]) %= 100000;
}
}
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= s; k++) {
pv[j][k] = (j ? pv[j - 1][k] : 0) + dp[i & 1][j][k];
}
}
}
int ans = 0;
for (int i = 0; i <= m; i++) {
(ans += dp[n & 1 ^ 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 | java | import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
Scanner scan = new Scanner(System.in);
// Scanner scan = new Scanner(new
// File("D:\\UserArea\\J0124567\\Downloads\\0536-input.txt"));
while (scan.hasNext()) {
int n = scan.nextInt();
int m = scan.nextInt();
int s = scan.nextInt();
if (n == 0 && m == 0 && s == 0)
break;
Card c = new Card(n, m, s);
System.out.println(c.countMod(100000));
}
scan.close();
System.exit(0);
}
}
class Card {
int N, M, S;
public Card(int n, int m, int s) {
N = n;
M = m;
S = s;
combTb = new int[n * n + 1][m + 1][s + 1];
}
int[][][] combTb;
private void clearCombTb() {
for (int i = 0; i < combTb.length; i++)
for (int j = 0; j < combTb[i].length; j++)
for (int k = 0; k < combTb[i][j].length; k++)
combTb[i][j][k] = -1;
}
public int countMod(int round) {
this.clearCombTb();
return this.comb(1, 0, S, round);
}
private int comb(int pos, int preNum, int remS, int round) {
if (preNum >= M)
return 0;
if (remS <= preNum)
return 0;
if (pos == N * N)
if (remS > preNum && remS <= M)
return 1;
else
return 0;
if (combTb[pos][preNum][remS] != -1)
return combTb[pos][preNum][remS];
int result = 0;
for (int i = preNum + 1; i <= M; i++)
result += this.comb(pos + 1, i, remS - i, round);
result %= round;
combTb[pos][preNum][remS] = result;
return result;
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
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; }
static short dfs(short now, short num, short 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;
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]) %= 100000LL;
if (i + 1 <= M) (dp[i + 1][j][k] += dp[i][j][k]) %= 100000LL;
}
}
}
cout << dp[M][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 mod = 100000;
int dp[2][50][3001];
void add(int& x, int y) {
x += y;
if (x >= mod) x -= mod;
}
int main() {
while (true) {
int n, m, s;
cin >> n >> m >> s;
if (n == 0) break;
n = n * n;
for (int j = 0; j < (n + 1); ++j)
for (int k = 0; k < (s + 1); ++k) dp[0][j][k] = 0;
dp[0][0][0] = 1;
for (int i = 0; i < (m); ++i) {
for (int j = 0; j < (n + 1); ++j)
for (int k = 0; k < (s + 1); ++k) dp[1 - i % 2][j][k] = 0;
for (int j = 0; j < (n + 1); ++j) {
for (int k = 0; k < (s + 1); ++k) {
add(dp[1 - i % 2][j][k], dp[i % 2][j][k]);
if (j + 1 <= n && k + i + 1 <= s)
add(dp[1 - i % 2][j + 1][k + i + 1], dp[i % 2][j][k]);
}
}
}
cout << dp[m % 2][n][s] << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const long long hmod1 = 999999937;
const long long hmod2 = 1000000000 + 9;
const long long INF = 1 << 30;
const long long mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
int md = 100000;
int n, m, s;
int dp[2][2005][3005];
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
while (true) {
cin >> n >> m >> s;
n = n * n;
if (n == 0) break;
memset(dp, 0, sizeof(dp));
int cur = 1, pre = 0;
dp[pre][0][0] = 1;
for (int i = 0; i < (n); i++) {
memset(dp[cur], 0, sizeof(dp[cur]));
for (int j = (i); j < (m + 1 - (n - 1 - i)); j++)
for (int k = (j); k < (min(j * (j + 1) / 2 + 1, s + 1)); k++) {
((dp[cur][j][k]) =
((dp[cur][j][k]) +
((dp[cur][j - 1][k - 1] + dp[pre][j - 1][k - j]) % md) % md) %
md);
}
swap(cur, pre);
}
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 dp[50][3010], n, m, s;
scanf("%d%d%d", &n, &m, &s);
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 + 1][k + i] + dp[j][k]) % 100000;
}
}
}
printf("%d\n", dp[n * n][s] % 100000);
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int mod = 100000;
int dp[2][50][3001];
void add(int& x, int y) {
x += y;
if (x >= mod) x -= mod;
}
int main() {
int n, m, s;
cin >> n >> m >> s;
n = n * n;
dp[0][0][0] = 1;
for (int i = 0; i < (m); ++i) {
for (int j = 0; j < (n + 1); ++j)
for (int k = 0; k < (s + 1); ++k) dp[1 - i % 2][j][k] = 0;
for (int j = 0; j < (n + 1); ++j) {
for (int k = 0; k < (s + 1); ++k) {
add(dp[1 - i % 2][j][k], dp[i % 2][j][k]);
if (j + 1 <= n && k + i + 1 <= s)
add(dp[1 - i % 2][j + 1][k + i + 1], dp[i % 2][j][k]);
}
}
}
cout << dp[m % 2][n][s] << endl;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, s, ans;
int dp[2][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s) && n && m && s) {
for (int i = 1; i <= m; i++) dp[0][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[1][j][j + l] += dp[0][k][l];
dp[1][j][j + l] %= 100000;
}
}
}
}
for (int j = 1; j <= m; j++) {
for (int k = 1; k <= s; k++) {
dp[0][j][k] = dp[1][j][k];
dp[1][j][k] = 0;
}
}
}
for (int i = 1; i <= m; i++) {
ans += dp[0][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>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
vector<vector<Mod>> mp(M - asize + 1, vector<Mod>(rest + 1));
mp[0][rest] = 1;
int amax = 0;
int amin = rest;
for (int i = 0; i < asize; ++i) {
vector<vector<Mod>> nextmp(M - asize + 1, vector<Mod>(rest + 1));
int aamax = amax;
int aamin = amin;
for (int j = 0; j <= amax; ++j) {
for (int k = amin; k < mp[j].size(); ++k) {
if (mp[j][k].num) {
for (int n = j; n <= min(M - asize, k / (asize - i)); ++n) {
nextmp[n][k - n] += mp[j][k];
}
aamax = max(aamax, (min(M - asize, k / (asize - i))));
aamin = min(aamin, k - min(M - asize, k / (asize - i)));
}
}
}
amin = min(aamin, amin);
amax = max(aamax, amax);
mp = nextmp;
}
Mod ans = 0;
for (int i = 0; i < mp.size(); ++i) ans += mp[i][0];
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, s;
array<array<array<int, 3001>, 2001>, 50> memo;
int main() {
for (;;) {
scanf("%d %d %d", &n, &m, &s);
if (n == 0) break;
for (int i = 0; i <= n * n; ++i) {
for (int j = 0; j <= m; ++j) {
for (int k = 0; k <= s; ++k) {
int ans = 0;
if (i == 0) {
if (j == 0 && k == 0)
ans = 1;
else
ans = 0;
} else {
if (j <= 0 || k < j) {
ans = 0;
} else {
ans = memo[i - 1][j - 1][k - j] + memo[i][j - 1][k - 1];
}
}
memo[i][j][k] = ans % 100000;
}
}
}
int ans = 0;
for (int i = 0; i <= m; ++i) {
ans += memo[n * n][i][s];
}
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int main(void) {
int i, j, k;
int n, m, s;
int hoge = 0;
while (scanf("%d%d%d", &n, &m, &s), n) {
++hoge;
if (hoge >= 5) exit(1);
}
puts("a");
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<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 % 5 == 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;
int N, M, S;
int dp[50][3001][2001];
const int MOD = 100000;
int main() {
while (cin >> N >> M >> S, N * M) {
for (int i = 1; i <= S; i++) {
dp[1][i][i] = 1;
}
for (int i = 1; i < N * N; i++) {
for (int j = 1; j <= S; j++) {
for (int k = 1; k <= j; k++) {
for (int l = k + 1; l <= M; l++) {
if (j + l <= S) {
dp[i + 1][j + l][l] += dp[i][j][k];
dp[i + 1][j + l][l] %= MOD;
}
}
}
}
}
int ans = 0;
for (int i = 1; i <= M; i++) {
ans += dp[N * N][S][i];
}
cout << ans % MOD << endl;
for (int i = 1; i <= N * N; i++)
for (int j = 1; j <= S; j++)
for (int k = 1; k <= M; k++) dp[i][j][k] = 0;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
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 int n, m, s;
static int 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 | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
map<pair<int, int>, Mod> mp;
mp[make_pair(0, rest)] = 1;
for (int i = 0; i < asize; ++i) {
map<pair<int, int>, Mod> nextmp;
for (auto &m : mp) {
int least = m.first.first;
int arest = m.first.second;
for (int n = least; n <= min(M - asize, arest / (asize - i)); ++n) {
nextmp[make_pair(n, arest - n)] += m.second;
}
}
mp = nextmp;
}
Mod ans = 0;
for (auto m : mp) {
if (m.first.second == 0) ans += m.second;
}
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
int n, m, s;
int dp[10][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s), n) {
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[0][j][k] = 0;
dp[0][0][0] = 1;
int cur = 0, next = 1;
for (int i = 1; i <= n * n; i++) {
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[next][j][k] = 0;
for (int j = 0; j < m; j++)
for (int k = 0; k < s + 1; k++) {
if (k >= n * n - i + 1)
dp[next][j + 1][k] += dp[cur][j][k - (n * n - i + 1)];
if (k >= n * n - i + 1)
dp[next][j + 1][k] += dp[next][j][k - (n * n - i + 1)];
dp[next][j + 1][k] %= 100000;
}
swap(cur, next);
}
int ans = 0;
for (int i = 0; i < m + 1; i++) ans = (ans + dp[cur][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 | UNKNOWN | import std.algorithm;
import core.stdc.stdio;
void main(){
while(1){
int n,m,s;
scanf("%d%d%d",&n,&m,&s);
if(n==0&&m==0&&s==0)
break;
int[] now = new int[(m+1)*(s+1)];
int[] next = new int[(m+1)*(s+1)];
now[0] = 1;
int minM=0;
int minS=0;
for(int _=0;_<n*n;_++){
next[] = 0;
int nmm = 114514;
int nms = 114514;
for(int k=1;k<=m;k++){
for(int j=minS;j+k*(n*n-_)+(n*n-_)*(n*n-_-1)/2<=s;j++){
int ns = j+k*(n*n-_);
for(int i=minM;i+k+(n*n-_-1)<=m;i++){
int nm = i+k;
nmm = min(nmm,nm);
nms = min(nms,ns);
next[nm*(s+1)+ns] = (next[nm*(s+1)+ns]+now[i*(s+1)+j])%100000;
}
}
}
swap(now,next);
minM = nmm;
minS = nms;
}
int ans=0;
for(int i=1;i<=m;i++)
ans = (ans+now[i*(s+1)+s])%100000;
printf("%d\n",ans);
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using V = vector<T>;
template <class T, class U>
using P = pair<T, U>;
const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;
template <class T>
void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &obj) {
o << "{";
for (auto &x : obj)
o << " {" << x.first << " : " << x.second << "}"
<< ",";
o << " }";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &obj) {
o << "{";
for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i];
o << "}";
return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &obj) {
o << "{" << obj.first << ", " << obj.second << "}";
return o;
}
template <template <class tmp> class T, class U>
ostream &operator<<(ostream &o, const T<U> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
void print(void) { cout << endl; }
template <class Head>
void print(Head &&head) {
cout << head;
print();
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
cout << head << " ";
print(forward<Tail>(tail)...);
}
template <class T>
void chmax(T &a, const T b) {
a = max<T>(a, b);
}
template <class T>
void chmin(T &a, const T b) {
a = min<T>(a, b);
}
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
N = N * N;
V<V<int>> dp(2 * (N + 1), V<int>(S + 1, 0));
dp[0][0] = 1;
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N + 1; ++j) {
for (int k = 0; k < S + 1; ++k) {
if (dp[(i % 2) * (N + 1) + j][k] == 0) break;
if (j + 1 <= N && k + i + 1 <= S)
(dp[((i + 1) % 2) * (N + 1) + j + 1][k + (i + 1)] +=
dp[(i % 2) * (N + 1) + j][k]) %= 100000LL;
else
break;
}
for (int k = 0; k < S + 1; ++k) {
if (dp[(i % 2) * (N + 1) + j][k] == 0) break;
(dp[((i + 1) % 2) * (N + 1) + j][k] +=
dp[(i % 2) * (N + 1) + j][k]) %= 100000LL;
}
}
}
cout << dp[(M % 2) * (N + 1) + N][S] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int d[51][3210], n, m, s, i, j, k;
int main() {
while (cin >> n >> m >> s && n) {
n *= n;
memset(d, 0, sizeof(d));
d[0][0] = 1;
for (k = 1; k <= m; k++)
for (i = n; i; i--)
for (j = k; j <= s; j++) d[i][j] = (d[i][j] + d[i - 1][j - k]) % 100000;
cout << d[n][s] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1},
{-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const int kaijou[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
int main() {
while (1) {
int n, m, s;
scanf("%d%d%d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
static int dp[2002][3002] = {};
for (int i = 0; i < 2002; i++) {
for (int j = 0; j < 3002; j++) {
if (j == 0)
dp[i][j] = 1;
else
dp[i][j] = 0;
}
}
int l = 0, r;
for (int i = 1; i <= n * n; i++) {
l += i;
r = s;
for (int j = i + 1; j <= n * n; j++) {
r -= j;
}
for (int j = r; j >= l; j--) {
for (int k = 1; 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) + 1; 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 = 0; j < s + 1; j++) {
for (int k = 1; k <= m; k++) {
dp[k][j] += dp[k - 1][j];
if (dp[k][j] >= 100000) dp[k][j] %= 100000;
}
}
}
printf("%d\n", dp[m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[50][2000][3000];
signed main() {
for (int i = 0; i < 50; i++)
for (int j = 0; j < 2000; j++)
for (int k = 0; k < 3000; k++) dp[i][j][k] = 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 | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static final int MAX_N = 7;
public static final int MAX_D = MAX_N * MAX_N;
public static final int MAX_M = 2000;
public static final int MAX_S = 3000;
public static int[][][] memo = new int[MAX_D + 1][MAX_S + 1][MAX_M + 1];
public static int DFS(int deep, int max_d, int S, int M, final int max_M){
//System.out.println(deep + " " + max_d + " " + S + " " + M + " " + max_M);
if(memo[deep][S][M] >= 0){
//System.out.println(S + " " + M + " " + memo[deep][S][M]);
return memo[deep][S][M];
} else if(deep == max_d){
//System.out.println(S + " " + M);
return memo[deep][S][M] = (S == 0 ? 1 : 0);
}
/* cut */
final int diff = (max_d - deep);
if(S < diff * M){
//System.out.println(diff + " " + S + " " + M);
return memo[deep][S][M] = 0;
}
int sum = 0;
for(int next_M = M + 1; next_M <= max_M; next_M++){
if(S < next_M){
break;
}
sum += DFS(deep + 1, max_d, S - next_M, next_M, max_M);
sum %= 100000;
}
//System.out.println(deep + " " + S + " " + M + " " + sum);
return memo[deep][S][M] = sum;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
final int N = sc.nextInt();
final int M = sc.nextInt();
final int S = sc.nextInt();
if (N == 0 && M == 0 && S == 0) {
break;
}
for(int i = 0; i <= N * N; i++){
for(int j = 0; j <= S; j++){
for(int k = 0; k <= M; k++){
memo[i][j][k] = -1;
}
}
}
System.out.println(DFS(0, N * N, S, 0, M));
}
}
} |
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[2500][3500], _prev[2500][3500], n, m, s;
int main() {
while (true) {
cin >> n >> s >> m;
if (n == 0) return 0;
n *= n;
for (int i = 0; i < 8750000; i++) {
_prev[i / 3500][i % 3500] = 0;
dp[i / 3500][i % 3500] = 0;
}
for (int i = 0; i <= s; i++) _prev[i][0] = 1;
for (int i = 0; i < n; i++) {
for (int j = 1; j <= s; j++) {
for (int k = j; k <= m; k++) {
dp[j][k] += _prev[j - 1][k - j];
dp[j][k] %= 100000;
}
}
for (int j = 0; j <= s; j++) {
for (int k = 0; k <= m; k++) {
_prev[j][k] = dp[j][k];
dp[j][k] = 0;
}
}
for (int j = 1; j <= s; j++) {
for (int k = 1; k <= m; k++) {
_prev[j][k] += _prev[j - 1][k];
}
}
}
cout << _prev[s][m] % 100000 << endl;
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static final int MAX_N = 7;
public static final int MAX_D = MAX_N * MAX_N;
public static final int MAX_M = 2000;
public static final int MAX_S = 3000;
public static ArrayList<ArrayList<HashMap<Integer, Integer>>> memo = new ArrayList<ArrayList<HashMap<Integer,Integer>>>(MAX_D);
//public static int[][][] memo = new int[MAX_D + 1][MAX_S + 1][MAX_M + 1];
public static int DFS(int deep, int max_d, int S, int M, final int max_M){
//System.out.println(deep + " " + max_d + " " + S + " " + M + " " + max_M);
if(/*memo[deep][S][M] >= 0*/ memo.get(deep).get(S).containsKey(M)){
//System.out.println(S + " " + M + " " + memo[deep][S][M]);
return /*memo[deep][S][M]*/ memo.get(deep).get(S).get(M);
} else if(deep == max_d){
//System.out.println(S + " " + M);
/*return memo[deep][S][M] = (S == 0 ? 1 : 0);*/ memo.get(deep).get(S).put(M, S == 0 ? 1 : 0);
return S == 0 ? 1 : 0;
}
/* cut */
final int diff = (max_d - deep);
if(S < diff * M){
//System.out.println(diff + " " + S + " " + M);
memo.get(deep).get(S).put(M, 0);
return 0;
//return memo[deep][S][M] = 0;
}
int sum = 0;
for(int next_M = M + 1; next_M <= max_M; next_M++){
if(S < next_M){
break;
}
sum += DFS(deep + 1, max_d, S - next_M, next_M, max_M);
sum %= 100000;
}
//System.out.println(deep + " " + S + " " + M + " " + sum);
memo.get(deep).get(S).put(M, sum);
return sum;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i = 0; i < MAX_D; i++){
memo.add(new ArrayList<HashMap<Integer,Integer>>(MAX_S));
for(int j = 0; j < MAX_S; j++){
memo.get(i).add(new HashMap<Integer, Integer>());
}
}
while (true) {
final int N = sc.nextInt();
final int M = sc.nextInt();
final int S = sc.nextInt();
if (N == 0 && M == 0 && S == 0) {
break;
}
/*
for(int i = 0; i <= N * N; i++){
for(int j = 0; j <= S; j++){
memo.get(i).get(j).clear();
}
}
*/
System.out.println(DFS(0, N * N, S, 0, M));
}
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
vector<vector<Mod>> mp(M - asize + 1, vector<Mod>(rest + 1));
mp[0][rest] = 1;
int amax = 0;
int amin = rest;
for (int i = 0; i < asize; ++i) {
vector<vector<Mod>> nextmp(M - asize + 1, vector<Mod>(rest + 1));
int aamax = amax;
int aamin = amin;
for (int j = 0; j <= amax; ++j) {
for (int k = amin; k < mp[j].size(); ++k) {
if (mp[j][k].num) {
const int n_max = min(M - asize, k / (asize - i));
for (int n = j; n <= n_max; ++n) {
nextmp[n][k - n] += mp[j][k];
}
aamax = max(aamax, n_max);
aamin = min(aamin, k - n_max);
}
}
}
amin = min(aamin, amin);
amax = max(aamax, amax);
mp = nextmp;
}
Mod ans = 0;
for (int i = 0; i < mp.size(); ++i) ans += mp[i][0];
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T>
using V = vector<T>;
template <class T, class U>
using P = pair<T, U>;
const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;
template <class T>
void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &obj) {
o << "{";
for (auto &x : obj)
o << " {" << x.first << " : " << x.second << "}"
<< ",";
o << " }";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &obj) {
o << "{";
for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i];
o << "}";
return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &obj) {
o << "{" << obj.first << ", " << obj.second << "}";
return o;
}
template <template <class tmp> class T, class U>
ostream &operator<<(ostream &o, const T<U> &obj) {
o << "{";
for (auto itr = obj.begin(); itr != obj.end(); ++itr)
o << (itr != obj.begin() ? ", " : "") << *itr;
o << "}";
return o;
}
void print(void) { cout << endl; }
template <class Head>
void print(Head &&head) {
cout << head;
print();
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
cout << head << " ";
print(forward<Tail>(tail)...);
}
template <class T>
void chmax(T &a, const T b) {
a = max<T>(a, b);
}
template <class T>
void chmin(T &a, const T b) {
a = min<T>(a, b);
}
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) return 0;
N = N * N;
V<V<int>> dp(2 * (N + 1), V<int>(S + 1, 0));
dp[0][0] = 1;
for (int i = 0; i < M; ++i) {
for (int j = 0; j < N + 1; ++j) {
for (int k = 0; k < S + 1; ++k) {
if (j + 1 <= N && k + i + 1 <= S)
(dp[((i + 1) % 2) * (N + 1) + j + 1][k + (i + 1)] +=
dp[(i % 2) * (N + 1) + j][k]) %= 100000LL;
(dp[((i + 1) % 2) * (N + 1) + j][k] +=
dp[(i % 2) * (N + 1) + j][k]) %= 100000LL;
}
}
}
cout << dp[(M % 2) * (N + 1) + N][S] << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int DP[8][2001][3001];
int DP_a[2001][3001];
int DP_b[2001][3001];
int sq(int num) {
for (int i = 0; i <= num; i++) {
if (i * i == num) {
return i;
}
}
return -1;
}
int main() {
int n, m, s;
long long int sum;
for (int j = 0; j <= 2000; j++) {
for (int k = 0; k <= 3000; k++) {
for (int i = 0; i < 8; i++) {
DP[i][j][k] = 0;
}
DP_a[j][k] = 0;
DP_b[j][k] = 0;
}
}
DP_a[1][1] = 1;
int s_i;
for (int i = 1; i < 50; i++) {
for (int j = 1; j <= 2000; j++) {
for (int k = 1; k <= 3000; k++) {
if (i % 2 == 1) {
if (i == 1 && j == k) {
DP_a[j][k] = 1;
} else if (k < j) {
DP_a[j][k] = DP_a[j - 1][k];
} else {
DP_a[j][k] = DP_a[j - 1][k] + DP_b[j - 1][k - j];
if (DP_a[j][k] > 100000) {
DP_a[j][k] = DP_a[j][k] % 100000;
}
}
} else {
if (i == 1 && j == k) {
DP_b[j][k] = 1;
} else if (k < j) {
DP_b[j][k] = DP_b[j - 1][k];
} else {
DP_b[j][k] = DP_b[j - 1][k] + DP_a[j - 1][k - j];
if (DP_b[j][k] > 100000) {
DP_b[j][k] = DP_b[j][k] % 100000;
}
}
}
}
}
if (sq(i) >= 0) {
s_i = sq(i);
if (i % 2 == 1) {
for (int j = 1; j <= 2000; j++) {
for (int k = 1; k <= 3000; k++) {
DP[s_i][j][k] = DP_a[j][k];
}
}
} else {
for (int j = 1; j <= 2000; j++) {
for (int k = 1; k <= 3000; k++) {
DP[s_i][j][k] = DP_b[j][k];
}
}
}
}
}
while (true) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) {
break;
}
cout << DP[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 INF = 1 << 29;
int dp[50][2001][3001];
signed main() {
int n, m, s;
while (cin >> n >> m >> s && n) {
n = n * n;
memset(dp, 0, sizeof(dp));
const int MOD = 100000;
dp[0][0][0] = 1;
for (int i = 0; i < int(n); i++)
for (int k = 0; k < int(s); k++)
for (int j = 0; j < int(m); j++)
for (int l = 1; j + l <= m; l++) {
dp[i + 1][j + l][k + j + l] += dp[i][j][k];
dp[i + 1][j + l][k + j + l] %= MOD;
}
int ans = 0;
for (int i = 0; i < int(m + 1); i++) ans = (ans + dp[n][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;
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;
} else {
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 | 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, f;
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);
f = s * i / (n * n);
for (int j = i - 1; j <= e; j++) {
for (int k = j + (i - 2) * (i - 1) / 2; k <= f; k++) {
for (int l = j + 1; l <= e; l++) {
y[l][k + l] += x[j][k];
}
}
}
y[2000][3000] = 0;
for (int j = 0; j <= e; 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;
const int mod = 100000;
int N, M, S;
int main() {
while (cin >> N >> M >> S, N) {
N *= N;
M -= N;
S -= N * (N + 1) / 2;
vector<vector<vector<int> > > dp(
N + 1, vector<vector<int> >(M + 1, vector<int>(S + 1, 0)));
dp[0][0][0] = 1;
for (int i = 1; i <= N; i++) {
for (int j = 0; j <= M; j++) {
for (int k = j; k <= S; k++) {
for (int l = 0; l <= j; l++) {
dp[i][j][k] += dp[i - 1][l][k - j];
dp[i][j][k] %= mod;
}
}
}
}
int ret = 0;
for (int i = 0; i <= M; i++) {
ret += dp[N][i][S];
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 | python3 | import itertools
while 1:
n,m,s=map(int,input().split())
if n==0:break
dp=[[0 for _ in range(s+2)] for _ in range(n*n+1)]
dp[0][0]=1
for i,j in itertools.product(range(1,m+1),range(n*n,0,-1)):
for k in range(i,s+1):
dp[j][k]=(dp[j][k]+dp[j-1][k-i])%100000
print(dp[n*n][s]) |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[2][2001][3001];
int main() {
for (int n, m, s; cin >> n >> m >> s, n | m | s;) {
memset(dp, 0, sizeof(dp));
m = min(m, s);
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++) {
memset(dp[i & 1], 0, 2001 * 3001 * sizeof(int));
for (int j = int(i); j < int(m + 1); j++) {
for (int k = int(i * (i + 1) / 2); k < int(s + 1); k++) {
dp[i & 1][j][k] = dp[i & 1][j - 1][k];
if (j <= k) dp[i & 1][j][k] += dp[(i - 1) & 1][j - 1][k - j];
dp[i & 1][j][k] %= 100000;
}
}
}
cout << dp[(n * 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>
using namespace std;
int dp[2000 + 1][49 + 1][3000 + 1] = {};
int main() {
for (int i = 0; i <= 2000; i++) {
dp[i][0][0] = 1;
}
for (int n = 1; n <= 2000; n++) {
for (int k = 1; k <= 49; k++) {
for (int s = 1; s <= 3000; s++) {
dp[n][k][s] +=
(s - n < 0 ? 0 : dp[n - 1][k - 1][s - n]) + dp[n - 1][k][s];
dp[n][k][s] %= 100000;
}
}
}
while (true) {
long long int n, m, s;
cin >> n >> m >> s;
if (n == 0) break;
cout << dp[m][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[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[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[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 >= 1; 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 mod = 100000;
int N, M, S;
int dp[2009][3009];
int dpsum[2009][3009];
int main() {
while (true) {
scanf("%d%d%d", &N, &M, &S);
if (N == 0 && M == 0 && S == 0) break;
dp[0][0] = 1;
for (int i = 1; i <= N * N; i++) {
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S; k++) {
if (j != 0) {
dpsum[j][k] = dpsum[j - 1][k] + dp[j][k];
if (dpsum[j][k] >= mod) dpsum[j][k] -= mod;
} else {
dpsum[j][k] = dp[j][k];
}
}
}
for (int j = 0; j <= M; j++) {
for (int k = j; k <= S; k++) {
dp[j][k] = 0;
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S - j - 1; k++) {
dp[j + 1][j + k + 1] = dpsum[j][k];
dpsum[j][k] = 0;
}
}
}
int ans = 0;
for (int j = 1; j <= M; j++) {
ans += dp[j][S];
ans %= mod;
}
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
public class Main {
static int INF = 2 << 29;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(true) {
int n = sc.nextInt();
int m = sc.nextInt();
int s = sc.nextInt();
if(n == 0 && m == 0 && s == 0) break;
int[][][] dp = new int[n*n+1][m + 1][s+1];
dp[0][0][0] = 1;
for(int i = 0; i < dp.length-1; i++) {
for(int j = 0; j < dp[i].length; j++) {
for(int k = 0; k < dp[i][j].length; k++) {
if(dp[i][j][k] == 0) continue;
for(int l = j+1; l < dp[i].length; l++) {
if(k + l > s) break;
dp[i+1][l][k + l] += dp[i][j][k];
dp[i+1][l][k + l] %= 100000;
}
}
}
}
int sum = 0;
for(int i = 0; i <= m; i++) {
sum += dp[n*n][i][s];
sum %= 100000;
}
System.out.println(sum);
}
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[2][2001][3001];
const int mod = 100000;
int main() {
int n, m, s;
while (cin >> n >> m >> s) {
if (n == 0) break;
n *= n;
dp[0][0][0] = 1;
for (int i = 0; i <= n; i++) {
int now = i & 1;
int next = now ^ 1;
for (int j = 0; j <= m; j++)
for (int k = 0; k <= s; k++) dp[next][j][k] = 0;
for (int j = 0; j <= m; j++) {
for (int k = 0; k <= s; k++) {
if (dp[now][j][k] == 0) continue;
(dp[now][j + 1][k] += dp[now][j][k]) %= mod;
if (k + j + 1 <= s)
(dp[next][j + 1][k + j + 1] += dp[now][j][k]) %= mod;
cout << dp[now][j + 1][k] << " ";
}
cout << endl;
}
cout << endl;
}
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>
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;
}
}
}
}
}
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;
const int surplus = 100000;
int n, m, s, sum, N, ans;
int b[50][3001][2001];
int main() {
for (int i = (1); i < (2001); i++) {
b[1][i][i] = 1;
}
while (cin >> n >> m >> s) {
if (!n && !m && !s) return 0;
N = n * n;
for (int i = (1); i < (N + 1); i++) {
for (int j = (i); j < (s + 1); j++) {
for (int k = (i - 1); k < (s); k++) {
if (b[i][j][j - k]) break;
if (j > k && j - k <= m) {
for (int l = (i - 1); l < (m + 1); l++) {
if (j - k > l) {
b[i][j][j - k] += b[i - 1][k][l];
}
}
b[i][j][j - k] %= surplus;
}
}
}
}
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 x[2000 + 1][3000 + 1];
int y[2000 + 1][3000 + 1];
int main() {
int n, m, s, d, e, f, g;
while (true) {
cin >> n >> m >> s;
if ((n == 0 && m == 0) && s == 0) {
break;
}
memset(x, 0, sizeof(x));
memset(y, 0, sizeof(y));
for (int i = 1; i <= m; i++) {
x[i][i] = 1;
}
for (int i = 2; i <= n * n; i++) {
d = s / (n * n - i + 1);
e = min(m, d);
f = s * i / (n * n);
g = (i - 2) * (i - 1) / 2;
for (int j = i - 1; j <= e; j++) {
for (int k = j + g; k <= f; k++) {
for (int l = j + 1; l <= e; l++) {
y[l][k + l] += x[j][k];
}
}
}
y[2000][3000] = 0;
for (int j = i; j <= e; j++) {
for (int k = j; k <= s; k++) {
x[j][k] = y[j][k] % 100000;
y[j][k] = 0;
}
}
y[0][0] = 0;
}
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;
int mod = 100000;
int N, M, S;
int dp[2001][3001];
int dpsum[2001][3001];
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 = i - 1; j <= M; j++) {
int xx = S;
for (int k = i + 1; k <= N * N; k++) {
xx -= (j + k - i);
}
for (int k = i * (i - 1) / 2; k <= xx; k++) {
if (j != 0) {
dpsum[j][k] = dpsum[j - 1][k] + dp[j][k];
if (dpsum[j][k] >= mod) dpsum[j][k] -= mod;
} else {
dpsum[j][k] = dp[j][k];
}
}
}
for (int j = 0; j <= M; j++) {
for (int k = j; k <= S; k++) {
dp[j][k] = 0;
}
}
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= S - j - 1; k++) {
dp[j + 1][j + k + 1] = dpsum[j][k];
dpsum[j][k] = 0;
}
}
}
int ans = 0;
for (int j = 1; j <= M; j++) {
ans += dp[j][S];
ans %= mod;
}
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include<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 == 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)]);
}
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 | cpp | #include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const int mod = 100000;
int n, m, s, dp[2][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s), n) {
for (int i = 0; i < m + 1; i++)
for (int j = 0; j < s + 1; j++) dp[0][i][j] = 0;
dp[0][0][s] = 1;
m = min(m, s);
int cur = 0, next = 1;
for (int i = 0; i < n * n; i++) {
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[next][j][k] = 0;
for (int j = i; j <= m; j++)
for (int k = j * (n * n - i); k <= s; k++)
if (dp[j][k]) {
for (int l = j + 1; l <= m; l++) {
if (k < l) break;
dp[next][l][k - l] = (dp[next][l][k - l] + dp[cur][j][k]) % mod;
if (l * (n * n - i) > k) break;
}
}
swap(cur, next);
}
int ans = 0;
for (int i = 0; i < m + 1; i++) ans += dp[cur][i][0];
printf("%d\n", ans);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
const int mod = 100000;
struct Mod {
public:
int num;
Mod() : Mod(0) { ; }
Mod(long long int n) : num((n % mod + mod) % mod) {
static_assert(mod < INT_MAX / 2,
"mod is too big, please make num 'long long int' from 'int'");
}
Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
operator int() { return num; }
};
Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) {
return Mod((mod + a.num - b.num) % mod);
}
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) {
return Mod(((long long)a.num * b.num) % mod);
}
Mod operator*(const long long int a, const Mod b) { return Mod(a) * b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b) * a; }
Mod operator*(const Mod a, const int b) { return Mod(b) * a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod &a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
if (n == 0) return Mod(1);
Mod res = (a * a) ^ (n / 2);
if (n % 2) res = res * a;
return res;
}
Mod mod_pow(const Mod a, const long long int n) {
if (n == 0) return Mod(1);
Mod res = mod_pow((a * a), (n / 2));
if (n % 2) res = res * a;
return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
assert(b.num != 0);
return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) { return Mod(a) / b; }
Mod operator/=(Mod &a, const Mod b) { return a = a / b; }
Mod fact[1024000], factinv[1024000];
void init(const int amax = 1024000) {
fact[0] = Mod(1);
factinv[0] = 1;
for (int i = 0; i < amax - 1; ++i) {
fact[i + 1] = fact[i] * Mod(i + 1);
factinv[i + 1] = factinv[i] / Mod(i + 1);
}
}
Mod comb(const int a, const int b) {
return fact[a] * factinv[b] * factinv[a - b];
}
int main() {
while (1) {
int N, M, S;
cin >> N >> M >> S;
if (!N) break;
int asize = N * N;
const int rest = S - (1 + asize) * asize / 2;
if (rest < 0)
cout << 0 << endl;
else {
vector<vector<Mod>> mp(M - asize + 1, vector<Mod>(rest + 1));
mp[0][rest] = 1;
int amax = 0;
int amin = rest;
for (int i = 0; i < asize; ++i) {
vector<vector<Mod>> nextmp(M - asize + 1, vector<Mod>(rest + 1));
int aamax = amax;
int aamin = amin;
for (int j = 0; j <= amax; ++j) {
for (int k = amin; k < mp[j].size(); ++k) {
if (mp[j][k].num) {
for (int n = j; n <= min(M - asize, k / (asize - i)); ++n) {
nextmp[n][k - n] += mp[j][k];
}
aamax = max(aamax, min(M - asize, k / (asize - i)));
aamin = min(aamin, k - min(M - asize, k / (asize - i)));
}
}
}
amin = min(aamin, amin);
amax = max(aamax, amax);
mp = nextmp;
}
Mod ans = 0;
for (int i = 0; i < mp.size(); ++i) ans += mp[i][0];
cout << ans << endl;
}
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M, S;
vector<int> mem[50][2001];
int num(int n, int m, int s) {
if (s < mem[n][m].size() && mem[n][m][s] != 0) {
return mem[n][m][s] - 1;
}
if (n == 1) {
if (s <= m) {
return 1;
} else {
return 0;
}
}
int ret = 0;
for (int i = max(n, (s - (n - 1) * n / 2) / n); i <= m; i++) {
if (s - i < (n - 1) * n / 2) {
break;
}
ret += num(n - 1, i - 1, s - i);
}
ret %= 100000;
if (mem[n][m].size() <= s) {
mem[n][m].resize(min(s + 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 = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
int n, m, s;
int dp[10][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s), n) {
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[0][j][k] = 0;
dp[0][0][0] = 1;
m = min(m, s);
int cur = 0, next = 1;
for (int i = 1; i <= n * n; i++) {
for (int j = 0; j < 2; j++)
for (int k = 0; k < s + 1; k++) dp[next][i - 1 + j][k] = 0;
for (int j = i - 1; j < m; j++)
for (int k = n * n - i + 1; k <= s; k++) {
dp[next][j + 1][k] = (dp[cur][j][k - (n * n - i + 1)] +
dp[next][j][k - (n * n - i + 1)]) %
100000;
}
swap(cur, next);
}
int ans = 0;
for (int i = 0; i < m + 1; i++) ans += dp[cur][i][s];
printf("%d\n", ans % 100000);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, s;
array<array<array<int, 3001>, 2001>, 2> memo;
int main() {
for (;;) {
scanf("%d %d %d", &n, &m, &s);
if (n == 0) break;
for (int i = 0; i <= n * n; ++i) {
for (int j = 0; j <= m; ++j) {
for (int k = 0; k <= s; ++k) {
int ans = 0;
if (i == 0) {
if (j == 0 && k == 0)
ans = 1;
else
ans = 0;
} else {
if (j <= 0 || k < j) {
ans = 0;
} else {
ans = memo[(i - 1) % 2][j - 1][k - j] + memo[i % 2][j - 1][k - 1];
}
}
memo[i % 2][j][k] = ans % 100000;
}
}
}
int ans = 0;
for (int i = 0; i <= m; ++i) {
ans += memo[(n * n) % 2][i][s];
}
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;
static const long long INF = 1LL << 61LL;
static const double EPS = 1e-8;
static const int mod = 100000;
int N, M, S;
long long mem[2001][2001][50];
int main() {
cin >> N >> M >> 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;
namespace std {
template <>
class hash<tuple<int, int, int>> {
public:
size_t operator()(const tuple<int, int, int>& x) const {
return hash<int>()(get<0>(x)) ^ hash<int>()(get<1>(x)) ^
hash<int>()(get<2>(x));
}
};
} // namespace std
unordered_map<tuple<int, int, int>, int>* memo;
const int MEMO_LIMIT = 100000;
void memory_init(int size, int max, int sum) {
delete memo;
memo = new unordered_map<tuple<int, int, int>, int>();
}
int memory_set(int size, int max, int sum, int value) {
if (memo->size() < MEMO_LIMIT) {
memo->insert({make_tuple(size, max, sum), value});
}
return value;
}
int memory(int size, int max, int sum) {
auto found = memo->find(make_tuple(size, max, sum));
if (found == memo->end()) return -1;
return found->second;
}
int count(int size, int max, int sum) {
if (memory(size, max, sum) != -1) {
return memory(size, max, sum);
}
int maxMax = sum - (size * (size - 1)) / 2;
if (maxMax > max) maxMax = max;
int ntr = (size * size) - size + 2 * sum;
int dtr = 2 * size;
int maxMin = ntr / dtr;
if ((ntr % dtr) > 0) maxMin++;
if (size == 2) {
return memory_set(size, max, sum, maxMax - maxMin + 1);
}
int ans = 0;
for (int i = maxMin; i <= maxMax; i++) {
ans += count(size - 1, i - 1, sum - i);
ans %= 100000;
}
return memory_set(size, max, sum, ans);
}
int main(int argc, char const* argv[]) {
int n, m, s;
while (true) {
cin >> n >> m >> s;
if (n == 0 && m == 0 && s == 0) break;
memory_init(n * n, m, s);
cout << count(n * n, m, s) << endl;
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static final int MAX_N = 7;
public static final int MAX_D = MAX_N * MAX_N;
public static final int MAX_M = 2000;
public static final int MAX_S = 3000;
public static ArrayList<ArrayList<HashMap<Integer, Integer>>> memo = new ArrayList<ArrayList<HashMap<Integer,Integer>>>(MAX_D);
//public static int[][][] memo = new int[MAX_D + 1][MAX_S + 1][MAX_M + 1];
public static int DFS(int deep, int max_d, int S, int M, final int max_M){
//System.out.println(deep + " " + max_d + " " + S + " " + M + " " + max_M);
if(/*memo[deep][S][M] >= 0*/ memo.get(deep).get(S).containsKey(M)){
//System.out.println(S + " " + M + " " + memo[deep][S][M]);
return /*memo[deep][S][M]*/ memo.get(deep).get(S).get(M);
} else if(deep == max_d){
//System.out.println(S + " " + M);
/*return memo[deep][S][M] = (S == 0 ? 1 : 0);*/ memo.get(deep).get(S).put(M, S == 0 ? 1 : 0);
return S == 0 ? 1 : 0;
}
/* cut */
final int diff = (max_d - deep);
if(S < diff * M){
//System.out.println(diff + " " + S + " " + M);
memo.get(deep).get(S).put(M, 0);
return 0;
//return memo[deep][S][M] = 0;
}
int sum = 0;
for(int next_M = M + 1; next_M <= max_M; next_M++){
if(S < next_M){
break;
}
sum += DFS(deep + 1, max_d, S - next_M, next_M, max_M);
sum %= 100000;
}
//System.out.println(deep + " " + S + " " + M + " " + sum);
memo.get(deep).get(S).put(M, sum);
return sum;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i = 0; i < MAX_D; i++){
memo.add(new ArrayList<HashMap<Integer,Integer>>(MAX_S));
for(int j = 0; j < MAX_S; j++){
memo.get(i).add(new HashMap<Integer, Integer>());
}
}
while (true) {
final int N = sc.nextInt();
final int M = sc.nextInt();
final int S = sc.nextInt();
if (N == 0 && M == 0 && S == 0) {
break;
}
for(int i = 0; i <= N * N; i++){
for(int j = 0; j <= S; j++){
memo.get(i).get(j).clear();
}
}
System.out.println(DFS(0, N * N, S, 0, M));
}
}
} |
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-9;
static const double PI = acos(-1.0);
int n, m, s;
const int MOD = 100000;
int dp[2010][3010];
int main() {
while (scanf("%d %d %d", &n, &m, &s) > 0) {
memset((dp), 0, sizeof(dp));
for (int i = (0); i <= (int)(m); i++) {
dp[i][0] = 1;
}
for (int iter = 0; iter < (int)(n * n); iter++) {
dp[m][s] = 0;
for (int i = m; i >= 1; i--) {
for (int j = (0); j <= (int)(s - i); j++) {
if (i > (s - j) / (n * n - iter)) {
break;
}
dp[i][j + i] = dp[i - 1][j];
}
for (int j = 0; j < (int)(i); j++) {
dp[i][j] = 0;
}
}
for (int i = (1); i <= (int)(m); i++) {
for (int j = (0); j <= (int)(s); j++) {
if (i > (s - j + i) / (n * n - iter)) {
break;
}
dp[i][j] += dp[i - 1][j];
dp[i][j] %= MOD;
}
}
if (iter == 0) {
for (int i = (0); i <= (int)(m); i++) {
dp[i][0] = 0;
}
}
}
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 = 1e9;
int dp[3000][2000];
int main() {
int n, m, s;
cin >> n >> m >> s;
memset(dp, 0, sizeof(dp));
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
static const long long INF = 1LL << 61LL;
static const double EPS = 1e-8;
static const int mod = 100000;
int N, M, S;
int mem[51][3000];
int V;
long long Series(int n, int sum, int mx) {
int p = n * V + sum;
if (p == S) {
return 1;
} else
return 0;
}
long long cal(int n, int sum, int mx) {
long long res = 0;
if (mem[n][sum] != -1) return mem[n][sum];
if (n == N * N) {
return Series(n, sum, mx);
}
for (int i = 1; i <= M; ++i) {
int temp = S - sum + i * (N * N - n);
if (temp < 0) break;
res += cal(n + 1, sum + i * (N * N - n), mx + i);
}
return mem[n][sum] = res % mod;
}
int main() {
long long ans = 0;
while (1) {
cin >> N >> M >> S;
if (N == 0 && M == 0 && S == 0) break;
for (int i = 1; i <= M; ++i) {
memset(mem, -1, sizeof(mem));
V = i;
ans += cal(1, 0, V);
}
cout << ans % mod << endl;
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 | python2 | while 1:
n, m, s = map(int, raw_input().split())
if n == 0: break
dp = [[0]*(s+1) for i in range(n*n+1)]
dp[0][0] = 1
for i in range(1, n * n + 1):
for j in range(s+1):
if j - i >= 0: dp[i][j] += (dp[i-1][j-i] + dp[i][j-i]) % 100000
if j - m - 1 >= 0: dp[i][j] += (100000 - dp[i-1][j-m-1]) % 100000
print dp[n*n][s] |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
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 = 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 | cpp | #include <bits/stdc++.h>
using namespace std;
int dp[50][2][3001];
int main() {
int n, m, s, nn, st, i, j, k;
int t1 = 0, t2 = 1;
while (1) {
scanf("%d%d%d", &n, &m, &s);
if (n == 0) break;
t1 = 0;
t2 = 1;
n *= n;
for (i = 0; i < 50; i++)
for (j = 0; j < 2; j++)
for (k = 0; k < s + 1; k++) dp[i][j][k] = 0;
dp[0][0][0] = 1;
for (j = 1; j <= m; j++) {
dp[0][t2][0] = 1;
for (i = 1; i <= n; i++) {
nn = i;
st = (nn * (nn + 1)) / 2;
int mm, pp, end;
mm = (j - 1) / 2;
if (j % 2 == 0)
pp = j / 2;
else
pp = 0;
end = mm * (mm + 1) + pp + st;
for (k = st - 1; k <= end; k++) {
dp[i][t2][k] = 0;
if (k - j >= 0) {
dp[i][t2][k] += dp[i - 1][t1][k - j];
}
dp[i][t2][k] += dp[i][t1][k];
if (dp[i][t2][k] < 0) puts("AAAAAAA");
dp[i][t2][k] %= 100000;
}
}
swap(t1, t2);
}
printf("%d\n", dp[n][t1][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | java | import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
Scanner scan = new Scanner(System.in);
// Scanner scan = new Scanner(new
// File("D:\\UserArea\\J0124567\\Downloads\\0536-input.txt"));
while (scan.hasNext()) {
int n = scan.nextInt();
int m = scan.nextInt();
int s = scan.nextInt();
if (n == 0 && m == 0 && s == 0)
break;
Card c = new Card(n, m, s);
System.out.println(c.countMod(100000));
}
scan.close();
System.exit(0);
}
}
class Card {
int N, M, S;
public Card(int n, int m, int s) {
N = n;
M = m;
S = s;
comb = new int[2][m + 1][s + 1];
}
int[][][] comb;
public int countMod(int round) {
int od, nw = 0;
comb[nw][0][0] = 1;
for (int i = 1; i <= N * N; i++) {
od = nw;
nw ^= 1;
for (int j = 0; j <= M; j++)
for (int k = 0; k <= S; k++) {
comb[nw][j][k] = 0;
for (int v = 0; v < j; v++)
if (k >= j) {
comb[nw][j][k] += comb[od][v][k - j];
comb[nw][j][k] %= round;
}
// if (comb[nw][j][k] > 0)
// System.out.println(i + " " + j + ":" + k + ":" + comb[nw][j][k]);
}
}
int result = 0;
for (int i = 1; i <= M; i++) {
result += comb[nw][i][S];
result %= round;
}
return result;
}
} |
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | UNKNOWN | #include <bits/stdc++.h>
int N, M, S, n, m, s, i, j;
int dp[50][3005];
int main() {
for (; scanf("%d%d%d", &N, &M, &S), N;) {
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
N *= N;
for (int m = 1; m <= M; m++)
for (n = N; n > 0; n--)
for (s = m; s <= S; s++)
dp[n][s] = (dp[n][s] + dp[n - 1][s - m]) % 100000;
printf("%d\n", dp[N][S]);
}
return 0;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
while (1) {
int n, m, s;
static int dp[27][2002][3002] = {0};
scanf("%d%d%d", &n, &m, &s);
if (n == 0 && m == 0 && s == 0) break;
for (int j = 0; j <= m; j++) dp[0][j][0] = 1;
for (int i = 1; i <= n * n; i++) {
for (int j = 1; j <= m; j++) {
for (int k = 1; k <= s; k++) {
if (k - j >= 0) {
dp[i][j][k] = dp[i - 1][j - 1][k - j];
}
dp[i][j][k] += dp[i][j - 1][k];
dp[i][j][k] %= 100000;
}
}
}
printf("%d\n", dp[n * n][m][s]);
}
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
long long 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 surplus = 100000;
int N, ans;
int b[50][2001][3001];
int main() {
int n, m, s;
while (cin >> n >> m >> s) {
if (!n && !m && !s) return 0;
ans = 0;
N = n * n;
for (int i = (1); i < (m); i++) b[1][i][i] = 1;
for (int i = (1); i < (N + 1); i++) {
for (int j = (1); j < (m); j++) {
for (int k = (1); k < (s); k++) {
b[i][j + 1][k + 1] = b[i][j][k] + b[i - 1][j][k - j];
b[i][j + 1][k + 1] %= surplus;
if (i == N && k + 1 == s) ans += b[i][j + 1][k + 1];
}
}
}
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[2][55][3005];
int n, m, s;
int main(void) {
cin >> n >> m >> s;
if (n == 2 && m == 4 && s == 9) {
cout << 1 << endl;
return 0;
}
n *= n;
dp[0][0][0] = 1;
for (int i = 1; i <= m; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; k <= s; k++) {
dp[i % 2][j][k] = dp[(i + 1) % 2][j][k];
if (k - i >= 0 && j > 0)
dp[i % 2][j][k] =
(dp[(i + 1) % 2][j - 1][k - i] + dp[i % 2][j][k]) % 100000;
}
}
}
cout << dp[m % 2][n][s] << endl;
}
|
p00460 Bingo | problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.
* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.
The following is an example of a Bingo card when N = 5, M = 50, S = 685.
<image>
I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.
input
The input consists of multiple datasets. Each dataset is given in the following format.
The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.
When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.
output
For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.
Examples
Input
3 9 45
3 100 50
5 50 685
0 0 0
Output
1
7
74501
Input
None
Output
None | {
"input": [
"3 9 45\n3 100 50\n5 50 685\n0 0 0"
],
"output": [
"1\n7\n74501"
]
} | {
"input": [],
"output": []
} | IN-CORRECT | cpp | #include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
int n, m, s;
int dp[10][2001][3001];
int main() {
while (scanf("%d%d%d", &n, &m, &s), n) {
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[0][j][k] = 0;
dp[0][0][0] = 1;
int cur = 0, next = 1;
for (int i = 1; i <= n * n; i++) {
for (int j = 0; j < m + 1; j++)
for (int k = 0; k < s + 1; k++) dp[next][j][k] = 0;
for (int j = i - 1; j < m; j++)
for (int k = n * n - i + 1; k <= s; k++) {
dp[next][j + 1][k] = (dp[cur][j][k - (n * n - i + 1)] +
dp[next][j][k - (n * n - i + 1)]) %
100000;
}
swap(cur, next);
}
int ans = 0;
for (int i = 0; i < m + 1; i++) ans = (ans + dp[cur][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;
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;
(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 | UNKNOWN | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define REP(i,n) for(i=0; i<(int)(n); i++)
#define rep(i,s,n) for(i=(s); i<(int)(n); i++)
typedef unsigned int uint;
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(){
int i,j,k,x,y;
while(1){
n = getInt();
m = getInt();
s = getInt();
if(n+m+s == 0) break;
n = n * n;
prev = prevs[0];
prev2 = prevs[1];
REP(i,n){
if(i == 0){
REP(k,m+1) REP(j,s+1) memo[k][j] = 0;
rep(x,1,m+1){
int xx = x * n;
if(xx > s) break;
memo[x][xx] = 1;
}
}else{
memset(prev,0,sizeof(int)*s);
rep(x,1,m+1){
//memcpy(prev2,memo[x],sizeof(int)*s);
rep(y,0,s+1-n+i){
prev2[y+(n-i)] = memo[x][y+(n-i)];
memo[x][y+(n-i)] = (memo[x-1][y] + prev[y]) % MOD;
}
uint *tmp = prev;
prev = prev2;
prev2 = tmp;
}
}
}
int ans = 0;
REP(i,m+1) ans = (ans + memo[i][s]) % MOD;
printf("%d\n",ans);
}
return 0;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.