Cod sursa(job #1125628)

Utilizator alexalghisiAlghisi Alessandro Paolo alexalghisi Data 26 februarie 2014 18:46:47
Problema Indep Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <iostream>
#include <fstream>

#define DN 505
#define LL long long
using namespace std;

LL dp[DN+DN],v[DN];

/// dp[j] = nr de subsiruri divizibile cu j

inline int cmmdc(LL a,LL b){

    int c;
    for(;b;){
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}

int main()
{
    int n;
    ifstream f("indep.in");
    ofstream g("indep.out");
    f>>n;

//    for(int j=1;j<=1000;++j)
//        if(v[1]%j == 0)
//            dp[1][j]=1;

    for(int i=1;i<=n;++i){

        LL x;
        f>>x;

        for(int j=1;j<=1000;++j)
            dp[ cmmdc(j,x) ] += dp[j];
        dp[x]+=1;
    }
    g<<dp[1];

    return 0;
}