Cod sursa(job #2266031)

Utilizator tiberiu392Tiberiu Ungurianu tiberiu392 Data 22 octombrie 2018 09:19:36
Problema 1-sir Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>
#define mod 194767

using namespace std;

ifstream f("1-sir.in");
ofstream g("1-sir.out");
int a[3][66000], n, m, i, j, s, x, y, l, h;

int main()
{
    f >> n >> s;
	x=1;
	y=2;
	a[1][0]=1;
	for(i=2;i<=n;i++)
	{
		l=(i-1)*i/2;
		for(j=0;j<=l;j++)
		{
			h=j-i+1;
			if(h<0)	h*=-1;
			a[y][j]=(a[x][j+(i-1)]+a[x][h])%mod;
		}
		h = x;
        x = y;
        y = h;
	}
	g << a[x][s]<<"\n";

    return 0;
}