Cod sursa(job #2273420)
| Utilizator | Data | 31 octombrie 2018 15:35:00 | |
|---|---|---|---|
| Problema | 1-sir | Scor | 80 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in ("1-sir.in");
ofstream out ("1-sir.out");
const int MOD = 194767;
int n, s, x;
bool ln, ln2;
int dp[2][32641];
int main() {
in >> n >> s;
x = n * (n - 1) / 2;
if(s > x || -x > s) {
out << 0;
return 0;
}
dp[1][0] = 1;
for(int i = 2; i <= n; i++, ln ^= 1) {
ln2 = ln ^ 1;
for(int j = 0; j <= x; j++)
dp[ln][j] = (dp[ln2][abs(j - i + 1)] + dp[ln2][abs(j + i - 1)]) % MOD;
}
out << dp[ln ^ 1][s];
return 0;
}
