Pagini recente » Cod sursa (job #2068796) | Cod sursa (job #1539102) | Cod sursa (job #1134186) | Cod sursa (job #2364166) | Cod sursa (job #2193186)
#include <stdio.h>
#include <vector>
using namespace std;
long long row, divider;
vector<long long> computedHalfRow(long long index) {
vector<long long> line;
line.push_back(1);
for ( int k = 0; k < index / 2; k++) {
line.push_back(line[k] * (index - k) / (k + 1));
}
return line;
}
int main() {
freopen("pascal.in", "r", stdin);
freopen("pascal.out", "w", stdout);
scanf("%lld %lld", &row, ÷r);
if (row == 0 || row == 1) {
printf("0\n");
return 0;
}
long long counter = 0;
long long ant = 1;
long long current = 0;
for (long long k = 0; k < row / 2; k++)
{
current = ant * (row - k) / (k + 1);
if (current % divider == 0) {
counter += 2;
}
ant = current;
}
if ( row % 2 == 0) {
if (current % divider == 0) {
counter -= 1;
}
}
printf("%lld\n", counter);
return 0;
}