Cod sursa(job #2694119)

Utilizator PatrickCplusplusPatrick Kristian Ondreovici PatrickCplusplus Data 8 ianuarie 2021 09:14:03
Problema Pascal Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.32 kb
#include <bits/stdc++.h>

using namespace std;

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

int r, d;

int main(){
    fin >> r >> d;
    for (int i = 0; i <= r / 2; ++i){
        int fr2[2] = {0, 0};
        int fr3[2] = {0, 0};
        if (d == 2 || d == 3 || d == 5 || d == 4){
            int n = i;
            int x = d;
            if (d == 4) x = 2;
            while (x <= n){
                fr2[0] += n / x;
                x = x * x;
            }
            n = r - i;
            x = d;
            if (d == 4) x = 2;
            while (x <= n){
                fr3[0] += n / x;
                x = x * x;
            }
        }
        else{
            int n = i;
            int x = 2;
            while (x <= n){
                fr2[0] += n / x;
                x = x * x;
            }
            x = 3;
            while (x <= n){
                fr2[1] += n / x;
                x = x * x;
            }
            n = r - i;
            x = 2;
            while (x <= n){
                fr3[0] += n / x;
                x = x * x;
            }
            x = 3;
            while (x <= n){
                fr3[1] += n / x;
                x = x * x;
            }
        }
    }
    fout << 0;
    fin.close();
    fout.close();
    return 0;
}