Pagini recente » Cod sursa (job #1564015) | Cod sursa (job #219407) | Cod sursa (job #1182381) | Cod sursa (job #519695) | Cod sursa (job #1450250)
#include <iostream>
#include <fstream>
#define cnst 40000
#define prim 194767
using namespace std;
int N,S,dp[2][100000]; bool l;
int main(){
ifstream fin("1-sir.in");
ofstream fout("1-sir.out");
fin >> N >> S;
dp[0][cnst]=1;
int i,j;
for (i=N; i>1; i--){
l=!l;
for (j=-N*(N-1)/2; j<=N*(N-1)/2; j++)
dp[l][j+cnst]=dp[!l][j+cnst-(N-i+1)]+dp[!l][j+cnst+(N-i+1)];
if (dp[l][j+cnst]>=prim) dp[l][j+cnst]-=prim;
}
fout << dp[l][S+cnst] << "\n";
return 0;
}