Cod sursa(job #222924)

Utilizator webspiderDumitru Bogdan webspider Data 26 noiembrie 2008 10:57:10
Problema 1-sir Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <stdio.h>
#include <iostream>

using namespace std;

const int maxN = 256;
const int maxS = maxN*(maxN-1)/2;
int D[2][ maxS + 10 ];
int N, S;

inline int mod( int X ) { return ( X < 0 ) ? -1*X : X; }
bool DEBUG;
int CR = 0;

int main()
{
#ifndef PC_RUN
	freopen("1-sir.in","r",stdin);
	freopen("1-sir.out","w",stdout);
	DEBUG = 0;
#else
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
	DEBUG = 1;
#endif
	
	scanf("%d %d\n", &N, &S );
	
	if ( S > (N*(N-1))/2 ) { printf("0\n"); return 0; }
	D[1][0] = 1;
	for ( int i = 2; i <= N; i++, CR = 1-CR ) 
		for ( int j = 1; j <= S; j++ ) {
			D[ CR ][ j ] = ( D[ 1-CR ][ mod(j-(i-1)) ] + D[ 1-CR ][ j+(i-1) ] ) % 194767;
		}	
	printf("%d\n", D[1-CR][S] );	

	return 0;
}