Pagini recente » Cod sursa (job #1942899) | Cod sursa (job #2784223) | Cod sursa (job #2384485) | Cod sursa (job #1860386) | Cod sursa (job #1222716)
#include <fstream>
#include <cstdlib>
#include <cstring>
const char IN [ ] = "1-sir.in" ;
const char OUT [ ] = "1-sir.out" ;
const int MAX = 69696 ;
const int MOD = 194767 ;
using namespace std;
ifstream fin ( IN ) ;
ofstream fout ( OUT ) ;
int mat [ 2 ] [ MAX ] ;
int main( )
{
int n , s ;
fin >> n >> s ;
int smax =( n * ( n - 1 ) ) >> 1 ;
s = abs ( s ) ;
if ( s > smax )
{
fout << 0 ;
return 0 ;
}
mat [ 0 ] [ 0 ] = 1 ;
for ( int i = 2 ; i <= n ; ++ i ){
for ( int j = 0 ; j <= smax ; ++ j )
mat [ 1 ] [ j ] = ( mat [ 0 ] [ j + i - 1 ] + mat [ 0 ] [ abs ( j - i + 1 ) ] ) % MOD ;
memcpy ( mat [ 0 ] , mat [ 1 ] , MAX ) ;
}
fout << mat [ 1 ] [ s ] % MOD ;
return 0;
}