Cod sursa(job #1912313)

Utilizator delia_ioanaCeapa Delia Ioana delia_ioana Data 8 martie 2017 00:52:27
Problema 1-sir Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <stdio.h>
#include <iostream>
#include <vector>
#include <climits>
#include <math.h>
#include <stdlib.h>

using namespace std;  

const int maxn = 257;
const int maxs = maxn * (maxn - 1);

int main() {
	  freopen("1-sir.in", "r", stdin);
	  freopen("1-sir.out", "w", stdout);

	  vector<vector<int> > d(maxn, vector<int>(maxs));

	  int n, s;
	  scanf("%d %d", &n, &s);

	  d[1][0] = 1;
	  s = abs(s);

	  if (s > (n * (n - 1)) / 2) {
	  	printf("0\n");
	  	return 0;
	  }

	  for (int i = 2; i <= n; i ++) {
	  	int lim = (i * (i - 1)) / 2;
	  	for (int j = 0; j <= lim; j ++) {
	  		d[i][j] = (d[i - 1][abs(j - (i - 1))] + d[i - 1][abs(j + (i - 1))]) % 194767;
	  	}
	  }

	  printf("%d", d[n][s]);

	  return 0;
}