Cod sursa(job #2672339)

Utilizator Alex_tz307Lorintz Alexandru Alex_tz307 Data 13 noiembrie 2020 18:14:29
Problema Pascal Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("pascal.in");
ofstream fout("pascal.out");

int main() {
    int N, D;
    fin >> N >> D;
    int ans = 0;
    vector < int > e(7);
    for(int i = 1; i <= N / 2; ++i) {
        int x = i;
        while(x % 2 == 0) {
            x /= 2;
            --e[2];
        }
        while(x % 3 == 0) {
            x /= 3;
            --e[3];
        }
        while(x % 5 == 0) {
            x /= 5;
            --e[5];
        }
        x = N - i + 1;
        while(x % 2 == 0) {
            x /= 2;
            ++e[2];
        }
        while(x % 3 == 0) {
            x /= 3;
            ++e[3];
        }
        while(x % 5 == 0) {
            x /= 5;
            ++e[5];
        }
        e[4] = e[2] / 2;
        e[6] = min(e[2], e[3]);
        if(e[D] > 0)
            ans += 2;
    }
    if(N % 2 == 0 && e[D] > 0)
        --ans;
    fout << ans;
}