Pagini recente » Cod sursa (job #800966) | Istoria paginii utilizator/gixvl | Statistici Ionas Robert Mihai (ionasrobert) | Profil raulion3331 | Cod sursa (job #2104989)
#include <iostream>
#include <fstream>
#define N 256
#define MOD 194767
using namespace std;
ifstream in ("1-sir.in");
ofstream out("1-sir.out");
int dp[2][N * N + 1];
int abs(int x) {
return (x < 0 ? -x : x);
}
int main() {
int n, s, mx, line = 1;
in >> n >> s;
mx = n * (n + 1) / 2;
if (s > mx || s < -mx) {
cout << 0;
return 0;
}
dp[0][0] = 1;
for (int i = 2; i <= n; i++) {
for (int j = 0; j <= mx; j++) {
dp[line][j] = (dp[1 - line][abs(j - (i - 1))] + dp[1 - line][abs(j + (i - 1))]) % MOD;
}
line = 1 - line;
}
out << dp[1 - line][s];
return 0;
}