C - ℕ Coloring ~mex解法~

// 抜粋
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // 素因数分解の準備
    prepare_factorize();

    // input
    ll N;cin>>N;
    
    VI Ans = {0};
    FOR(i,2,N+1){
      // 約数一覧
      VI D = calc_devisors(i);
      set<ll> se;
      for(ll d : D){
        if(d==i)continue;
        se.insert(Ans[d-1]);
      }
      ll m = mex(se);
      Ans.push_back(m);
    }
    print_vector(Ans,+1);
    
    return 0;
}