Cod sursa(job #2415397)

Utilizator Rufus007Marincia Catalin Rufus007 Data 25 aprilie 2019 22:15:55
Problema Pascal Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("pascal.in");
ofstream fout("pascal.out");
int C(int n, int k) {
  if (k == 0 || k == n)
    return 1;
  else
    return C(n - 1, k - 1) + C(n - 1, k);
}
int main() {
  int R, N;
  fin >> R >> N;
  int total = 0;
  for (int i = 0; i < R / 2; ++i)
    if (C(R, i) % N == 0) {
      total++;
    }
  total = total * 2;
  if (R % 2 == 0)
    if (C(R, R / 2) % N == 0)
      total++;
  fout << total;
  return 0;
}