Pagini recente » Diferente pentru preoni-2007/runda-finala/poze/pregatiri intre reviziile 3 si 6 | Istoria paginii utilizator/droppedt | Statistici Stoica Ioana Raluca (ioana126) | Istoria paginii runda/graf3 | Cod sursa (job #1990247)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int nMax = 260;
const int sMax = (nMax * (nMax - 1)) / 2;
const int MOD = 194767;
int n, s;
int dp[sMax];
void citire()
{
ifstream in("1-sir.in");
in >> n >> s;
in.close();
}
void rezolvare()
{
ofstream out("1-sir.out");
s = abs(s);
if(s > n * (n-1) / 2)
{
out << 0;
return;
}
s = n * (n - 1) / 2 - s;
if(s % 2 != 0)
{
out << 0;
return;
}
s /= 2;
--n;
dp[1] = dp[0] = 1;
for(int i = 2; i <= n; ++i)
for(int j = s; j >= i; --j)
dp[j] = (dp[j] + dp[j-i]) % MOD;
out << dp[s];
}
int main()
{
citire();
rezolvare();
return 0;
}