Cod sursa(job #508183)

Utilizator stanescumalinStanescu Malin Octavian stanescumalin Data 7 decembrie 2010 18:57:29
Problema Pascal Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include "stdafx.h"
#include <iostream.h>
#include <fstream.h>
//#include <string.h>


long fact(long x, long y){
	long f;
	if(x == y){
		return 1;
	}
	else{
		f = fact(x-1, y);
		f = f*x; 
		return f;
	}
	
}

int main(int argc, char* argv[])
{
	long i, j, cnt=0, d;
	ifstream fin("pascal.in");
	fin>>i;
	fin>>d;
	for(j=0; j<=i; j++){
		if ((fact(i, j)/fact(i-j, 0))%d == 0) cnt++;
	}
	ofstream fout("pascal.out");
	fout<<cnt;
	return 0;
}