Pagini recente » Cod sursa (job #1924211) | Cod sursa (job #1130289) | Cod sursa (job #1636734) | Cod sursa (job #1345931) | Cod sursa (job #838165)
Cod sursa(job #838165)
#include <stdio.h>
#define MOD 194767
inline void baga(int &A, int B)
{
A += B;
if (A >= MOD)
A = A - MOD;
}
inline int ab(int X)
{
if (X > 0)
return X;
return X * (-1);
}
int dp[2][90000];
int main()
{
int i, j, N, S, lim;
freopen("1-sir.in", "r", stdin);
freopen("1-sir.out", "w", stdout);
scanf("%d%d", &N, &S);
S = ab(S);
lim = N * (N + 1) / 2;
if (lim < S)
{
printf("0");
return 0;
}
int sol = 0;
dp[1][0] = 1;
for (i = 1; i <= N; i ++)
for (j = 0; j <= lim; j ++)
{
if (j + i <= lim)
baga(dp[(i + 1) & 1][j + i], dp[i & 1][j]);
if (ab(j - i) <= lim)
baga(dp[(i + 1) & 1][ab(j - i)], dp[i & 1][j]);
if (i == N && j == S)
sol = dp[i & 1][j];
dp[i & 1][j] = 0;
}
printf("%d", sol / 2);
return 0;
}