Cod sursa(job #2465471)

Utilizator CyborgSquirrelJardan Andrei CyborgSquirrel Data 30 septembrie 2019 10:25:14
Problema Indep Scor 5
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.95 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>

using namespace std;

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

int gcd(int a, int b){
    if(a == 0){
        return b;
    }
    return gcd(b%a, a);
}

int n;
int frecc[1041];

int kapow(int a, int p){
    int r = 1;
    for(int i = 0; i < p; i++){
        r *= a;
    }
    return r;
}

int susta(int a){
    int d, nd;
    d = nd = 0;
    for(int i = a+1; i <= 1000; i++){
        if(i % a == 0){
            d += frecc[i];
        }else{
            nd += frecc[i];
        }
    }
    cout << a << " " << d  << " " << nd << " " << "\n";
    return (kapow(2, nd)-1) * kapow(2, d);
}

int main(){
    int a;
    fin >> n;
    for(int i = 0; i < n; i++){
        fin >> a;
        frecc[a]++;
    }
    
    int sol = 0;
    for(int i = 2; i <= 1000; i++){
        sol += susta(i);
    }
    fout << sol;
    return 0;
}