Pagini recente » Cod sursa (job #1597843) | Cod sursa (job #2673379) | Cod sursa (job #1104042) | Cod sursa (job #1539809) | Cod sursa (job #2042568)
#include <bits/stdc++.h>
using namespace std;
ifstream f("stirling.in");
ofstream g("stirling.out");
const int NMax = 203;
int stir1[NMax][NMax],stir2[NMax][NMax];
int x,n,m,t;
int main()
{
f >> t;
stir1[1][1] = 1;
stir2[1][1] = 1;
for(int i = 1; i <= NMax - 2; ++i){
for(int j = 1; j <= NMax - 2; ++j){
if(i == 1 && j == 1)
continue;
stir1[i][j] = stir1[i - 1][j - 1] - (i - 1) * stir1[i - 1][j];
stir2[i][j] = stir2[i - 1][j - 1] + j * stir2[i - 1][j];
}
}
while(t--){
f >> x >> n >> m;
if(x == 1){
g << stir1[n][m] << '\n';
}else{
g << stir2[n][m] << '\n';
}
}
return 0;
}