Pagini recente » Cod sursa (job #2976262) | Cod sursa (job #1351401) | Cod sursa (job #3163923) | Cod sursa (job #1637070) | Cod sursa (job #1671888)
#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);
unsigned short maxS = n * (n-1) / 2;
if(s > maxS) {
g<<"0\n";
return 0;
}
dp[!line][0] = 1;
for(unsigned short i=2; i<=n; i++) {
for(unsigned short targetS=0; targetS <= maxS; targetS++)
dp[line][targetS] = (dp[!line][abs(targetS - (i-1))] + dp[!line][targetS + (i-1)]) % 194767;
line = !line;
}
g<<dp[!line][s]<<"\n";
return 0;
}