Pagini recente » Cod sursa (job #3207956) | Cod sursa (job #136340) | Cod sursa (job #3224375) | Cod sursa (job #853831) | Cod sursa (job #8226)
Cod sursa(job #8226)
#include <cstdio>
using namespace std;
const char iname[] = "1-sir.in";
const char oname[] = "1-sir.out";
#define lim 66050
#define modulo 194767
int cnt[2][lim * 2];
int Res;
int main(void) {
freopen(iname, "r", stdin);
int N;
int S;
scanf("%d %d", & N, & S);
freopen(oname, "w", stdout);
if ((S < - N * (N - 1) / 2) || (S > + N * (N - 1) / 2)) {
printf("0\n");
return 0;
}
int stp = 1;
cnt[stp][0 + lim] = 1;
for (int i = stp = 1; i < N; ++i) {
int inf = - i*(i-1)/2;
int sup = + i*(i-1)/2 + 1;
for (int j = inf; j < sup; ++j)
cnt[stp ^ 1][j + lim] = (cnt[stp][j - i + lim] + cnt[stp][j + i + lim]) % modulo;
stp ^= 1;
}
printf("%d\n", cnt[stp][S + lim]);
return 0;
}