Cod sursa(job #2195768)

Utilizator AndreiVisoiuAndrei Visoiu AndreiVisoiu Data 17 aprilie 2018 12:48:20
Problema Pascal Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.09 kb
#include <fstream>
#include <iostream>

using namespace std;

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

short ap[3][50000000];

void computeFact(int n) {
    for(int i = 2; i <= n; i++) {
        int k = i, c = 0;
        while(k%2 == 0) {
            k /= 2;
            c++;
        }
        ap[0][i] = ap[0][i-1]+c;

        k = i;
        while(k%3 == 0) {
            k /= 3;
            c++;
        }
        ap[1][i] = ap[1][i-1]+c;

        k = i;
        while(k%5 == 0) {
            k /= 5;
            c++;
        }
        ap[2][i] = ap[2][i-1]+c;
    }
}
/*
int legendre(int n, int k) {
    int r = n/k, s = 0, exp = k;
    while(r != 0) {
        s += r;
        exp *= k;
        r = n/exp;
    }
    return s;
}
*/
int main()
{
    int r, d, s = 0, p[3];
    in >> r >> d;

    for(int j = 1; j < r; j++)
        if(ap[0][r] - ap[0][j] - ap[0][r-j] >= ap[0][d] &&
           ap[1][r] - ap[1][j] - ap[1][r-j] >= ap[1][d] &&
           ap[2][r] - ap[2][j] - ap[2][r-j] >= ap[2][d])
            s++;

    out << s;
    return 0;
}