Pagini recente » Cod sursa (job #2377224) | Cod sursa (job #954050) | Cod sursa (job #2405591) | Cod sursa (job #163448) | Cod sursa (job #1168553)
#include <fstream>
#include <cstring>
using namespace std;
#define MID 50000
#define MOD 194767
ifstream is("1-sir.in");
ofstream os("1-sir.out");
int n, S, G;
int DP[2][100000], LC = 1, LP;
int main()
{
is >> n >> G;
DP[0][MID] = 1;
for (int i = 1; i < n; ++i, swap(LC, LP))
{
S += i;
memset(DP[LC], 0, sizeof(DP[LC]));
for (int j = MID-S; j <= MID+S; ++j)
{
DP[LC][j] = DP[LP][j-i]+DP[LP][j+i];
if (DP[LC][j] >= MOD) DP[LC][j] -= MOD;
}
}
os << DP[LP][MID+G];
is.close();
os.close();
}