Cod sursa(job #1168553)
| Utilizator | Data | 8 aprilie 2014 22:21:22 | |
|---|---|---|---|
| Problema | 1-sir | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#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();
}
