Cod sursa(job #2147559)
| Utilizator | Data | 28 februarie 2018 20:27:44 | |
|---|---|---|---|
| Problema | 1-sir | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("1-sir.in");
ofstream fout("1-sir.out");
int n,s,i,j,h,l,a,b,mod=194767,d[3][66000];
int main () {
fin>>n>>s;
a=1; b=2;
d[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;
d[b][j]=(d[a][j+(i-1)]+d[a][h])%mod;
}
h=a; a=b; b=h;
}
fout<<d[a][s]<<"\n";
}
