Cod sursa(job #2502651)

Utilizator radugheoRadu Mihai Gheorghe radugheo Data 1 decembrie 2019 12:50:59
Problema Pascal Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.26 kb
#include <bits/stdc++.h>

using namespace std;

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

int r, d, i, x, y, n;
int f[10][5000005];

int main(){
    fin >> r >> d;
    for (i=2; i<=r; i++){
        if (i%2 == 0){
            f[2][i] = f[2][i/2] + 1;
        }
        if (i%3 == 0){
            f[3][i] = f[3][i/3] + 1;
        }
        if (i%5 == 0){
            f[5][i] = f[5][i/5] + 1;
        }
    }
    if (d == 2){
        for (i=1; i<=r; i++){
            x += f[2][r-i+1] - f[2][i];
            if (x > 0)
                n++;
        }
    }
    if (d == 3){
        for (i=1; i<=r; i++){
            x += f[3][r-i+1] - f[3][i];
            if (x > 0)
                n++;
        }
    }
    if (d == 4){
        for (i=1; i<=r; i++){
            x += f[2][r-i+1] - f[2][i];
            if (x > 1)
                n++;
        }
    }
    if (d == 5){
        for (i=1; i<=r; i++){
            x += f[5][r-i+1] - f[5][i];
            if (x > 0)
                n++;
        }
    }
    if (d == 6){
        for (i=1; i<=r; i++){
            x += f[2][r-i+1] - f[2][i];
            y += f[3][r-i+1] - f[3][i];
            if (x > 0)
                n++;
        }
    }
    fout << n;
    return 0;
}