Pagini recente » Cod sursa (job #68295) | Cod sursa (job #1518207)
#include <fstream>
using namespace std;
ifstream fin ("1-sir.in");
ofstream fout ("1-sir.out");
const int MOD = 194767;
int n, s;
int V[2][257 * 257];
inline int Abs(int x)
{
if (x < 0) return -x;
return x;
}
int main()
{
fin >> n >> s;
int s_max = n * (n - 1) / 2;
V[1][0] = 1;
for (int i = 2; i <= n; i ++)
{
for (int j = 0; j <= s_max; j ++)
{
V[i & 1][j] = V[!(i & 1)][Abs(j - (i - 1))] + V[!(i & 1)][j + (i - 1)];
if (V[i & 1][j] >= MOD) V[i & 1][j] -= MOD;
}
}
fout << V[n & 1][s] << '\n';
fout.close();
return 0;
}