Pagini recente » Cod sursa (job #1726877) | Cod sursa (job #1223266) | Cod sursa (job #760702) | Cod sursa (job #1220922) | Cod sursa (job #1671881)
#include <bits/stdc++.h>
#define nmax 260
using namespace std;
int n, s;
int dp[2][nmax*nmax];
bool line=1;
int main() {
ifstream f("1-sir.in");
ofstream g("1-sir.out");
f>>n>>s;
s = abs(s);
int maxS = n * (n-1) / 2;
if(s > maxS) {
g<<"0\n";
return 0;
}
dp[!line][0] = 1;
for(int i=2; i<=n; i++) {
for(int targetS=0; targetS <= maxS; targetS++)
dp[line][targetS] = (dp[!line][abs(targetS - (i-1))] + dp[!line][abs(targetS + (i-1))]) % 194767;
//for(int targetS=0; targetS <= maxS; targetS++)
// dp[0][targetS] = dp[1][targetS];
line = !line;
}
/*
for(int i=1; i<=n; i++) {
for(int targetS=0; targetS <= maxS; targetS++) {
cout<<dp[i][targetS]<<" ";
}
cout<<"\n";
}
*/
g<<dp[!line][s]<<"\n";
return 0;
}