Pagini recente » Istoria paginii runda/jc2019-runda-1 | Cod sursa (job #448543) | Cod sursa (job #1214883) | Cod sursa (job #1291469) | Cod sursa (job #1532493)
#include <fstream>
#include <iostream>
using namespace std;
ifstream in("1-sir.in");
ofstream out("1-sir.out");
int n, s;
const int modulo = 194767;
const int jumate = 256 / 2 * 257;
int main() {
in >> n >> s;
int smax = (n-1)*n / 2;
s = s < 0 ? -s : s;
s = smax - s;
int a[s + 1];
for (int i = 0; i <= s; a[i++] = 0);
a[0] = 1;
for (int i = 1; i < n; ++i) {
for (int j = s; j >= 0; --j) {
if (a[j]) {
if (i == 1) cout << j << " ";
if (j + 2 * i <= s) {
a[j + 2 * i] += a[j];
}
}
}
}
out << a[s];
return 0;
}