Pagini recente » Cod sursa (job #2870214) | Cod sursa (job #1500001) | Cod sursa (job #305332) | Cod sursa (job #980081) | Cod sursa (job #63143)
Cod sursa(job #63143)
#include <cstdio>
using namespace std;
int abs(int a)
{
if(a > 0)
return a;
else
return -a;
}
void swap(int &a,int &b)
{
int aux = a;
a = b;
b = aux;
}
int a[2][35100];
int main()
{
freopen("1-sir.in","r",stdin);
freopen("1-sir.out","w",stdout);
int i,n,s, lim;
scanf("%d%d",&n,&s);
s = abs(s);
lim = n*(n-1)/2;
if(abs(lim)<s)
{
printf("0\n");
return 0;
}
int p1=0,p2=1, j;
#define MOD 194767
a[p1][0] = 1;
for(i=1;i<n;++i)
{
for(j=0;j<i;++j)
{
a[p2][j] = a[p1][j+i] + a[p1][i-j];
if(a[p2][j] > MOD)
a[p2][j] -= MOD;
}
for(j=i;j<=lim;++j)
{
a[p2][j] = a[p1][j+i] + a[p1][j-i];
if(a[p2][j] > MOD)
a[p2][j] -= MOD;
}
swap(p1,p2);
}
printf("%d\n",a[p1][s]);
return 0;
}