Cod sursa(job #1108067)
Utilizator | Data | 15 februarie 2014 13:04:16 | |
---|---|---|---|
Problema | Pascal | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("pascal.in");
ofstream out("pascal.out");
int main()
{
int n, c, z = 0;
in>>n>>c;
int i, j, mat[20][20];
mat[0][0] = 1;
mat[1][0] = 1; mat[1][1] = 1;
mat[2][0]=1; mat[2][1]=2; mat[2][2]=1;
for(i = 3; i <= n; i++)
{
mat[i][0]=1;
for(j = 1; j < i; j++) mat[i][j] = mat[i-1][j-1] + mat[i-1][j];
mat[i][i] = 1;
}
for(int i = 0; i <= n; i++)
if(mat[n][i] % c == 0) z++;
out<<z;
}