Pagini recente » Cod sursa (job #1314089) | Cod sursa (job #3267112) | Cod sursa (job #2426896) | Cod sursa (job #1210515) | Cod sursa (job #1073484)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream fin("1-sir.in");
ofstream fout("1-sir.out");
const int Nmax = 260;
const int Smax = (256 * 257) / 2 + 20;
const int MOD = 194767;
int N, S, smax;
vector <int> A(Smax), B(Smax);
int main()
{
fin>>N>>S;
if(S < 0) S = -S;
smax = N * (N + 1) / 2;
if(S > smax)
{
fout<<"0";
return 0;
}
A[0] = 1;
for(int i=2; i <= N; i++)
{
for(int j=0; j<=smax; j++)
B[j] = (A[abs(j - (i - 1))] + A[j + (i-1)]) % MOD;
swap(A, B);
}
fout<<A[S];
return 0;
}