Cod sursa(job #3291020)

Utilizator Dia3141Costea Diana Stefania Dia3141 Data 3 aprilie 2025 00:10:08
Problema 1-sir Scor 90
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
#include <cmath>
#include <cstring>
#define mod 194767
using namespace std;
ifstream cin("1-sir.in");
ofstream cout("1-sir.out");
int dp[2][32650],t,n,s;
signed main()
{
    cin>>n>>s;
    if(s<0)
        s*=(-1);
    if(s>n*(n-1)/2){
        cout<<0;
        return 0;
    }
    dp[1][0]=1;
    for(int i=1;i<n;i++){
        memset(dp[t],0,sizeof(dp[t]));
        for(int j=0;j<=n*(n-1)/2;j++)
            dp[t][j]=(dp[t][j]+dp[1-t][abs(j-i)]+dp[1-t][j+i])%mod;
        t=1-t;
    }
    cout<<dp[1-t][s];
    return 0;
}