Pagini recente » Cod sursa (job #2793711) | Cod sursa (job #904461) | Borderou de evaluare (job #2012356) | Cod sursa (job #818165) | Cod sursa (job #2750657)
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
const int smax = 65800;
const int dep = 32900;
const int nmax = 260;
int memo[smax][nmax];
const int mod = 194767;
int solve(int S, int N)
{
if(S + dep >= smax)
return 0;
if(N == 1)
{
if(!S)
return 1;
return 0;
}
if(memo[S + dep][N] != -1)
return memo[S + dep][N];
long long ans = 0;
ans += solve(S - N + 1, N - 1);
ans %= mod;
ans += solve(S + N - 1, N - 1);
ans %= mod;
return memo[S + dep][N] = ans;
}
int main() {
memset(memo, -1, sizeof(memo));
ifstream in("1-sir.in");
ofstream out("1-sir.out");
int N, S;
in >> N >> S;
out << solve(S, N) << "\n";
in.close();
out.close();
return 0;
}