Cod sursa(job #2105476)
| Utilizator | Data | 13 ianuarie 2018 13:45:30 | |
|---|---|---|---|
| Problema | Numerele lui Stirling | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
#include<fstream>
#define DN 205
#define M 98999
using namespace std;
ifstream fin("stirling.in");
ofstream fout("stirling.out");
int n,dp1[DN][DN],dp2[DN][DN],m,t,type;
int main()
{
dp1[1][1]=dp2[1][1]=1;
for(int i=2;i<DN;i++)
for(int j=1;j<=i;j++)
{
dp1[i][j]=(dp1[i-1][j-1]-(i-1)*dp1[i-1][j])%M;
dp2[i][j]=(dp2[i-1][j-1]+j*dp2[i-1][j])%M;
}
fin>>t;
for(int h=1;h<=t;h++)
{
fin>>type>>n>>m;
if(type==1)
fout<<dp1[n][m]<<'\n';
else
fout<<dp2[n][m]<<'\n';
}
}
