Cod sursa(job #2257157)

Utilizator DRLDRLRaul Ronald Galea DRLDRL Data 9 octombrie 2018 19:02:19
Problema 1-sir Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#pragma once

#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>

using namespace std;

ifstream fin("1-sir.in");
ofstream fout("1-sir.out");

#define dim 70000
#define N 256

// dp[n][s] - # moduri de obtinut suma s cu un 1 sir de n elem

int dp[2][dim];

void bu(int n, int s) {
	int c;
	dp[1][0] = 1;
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= s; j++) {
			dp[i % 2][j] = (dp[abs(i % 2 - 1)][abs(j - (i - 1))] + dp[abs(i % 2 - 1)][j + (i - 1)]) % 194767;
		}
	}
}

int main() {
	int n, s;
	fin >> n >> s;
	bu(n, s);
	fout << dp[n%2][s] % 194767;
	return 0;
}