// ///////////////////////////////// // mikbitsetA1.c++ // // A132581 terms. // (this program is Different from the one // that calculates terms of the A132582 series) // Read the comments at the end. // MIT Licensed source code. // // J.M. Aranda. Madrid. 2021. ///////////////////////////// #include #include #include #include #include #include #include #include using namespace std; ///////////////////////////////////////////// #pragma pack(16) #define WIDE 256 using typeposet=bitset; using typesize=boost::multiprecision::uint128_t; static std::unordered_map MAP; static array powers; //////////////////////////////////// // // poset: poset expressed as bitset. // result: size of the poset. static typesize POSETSIZE(const typeposet poset) { if(poset.none())return +1; // (0,+1) if(poset.count()==1)return +2; // (1,+2) // If value known take from map. auto ite=MAP.find(poset); if(ite!=MAP.end())return ite->second; ///////////////////////////////////// // Determine log2(poset) int posethb=-1;typeposet tmp=poset; while(tmp.any()){posethb++;tmp>>=1;} // // Split on left and right posets. typeposet left=poset; // left Poset P-{x} left&=~powers[posethb]; typesize Fleft=POSETSIZE(left); // typeposet right=poset; // right Poset P-cone(x) for(int i=0;i<=posethb;i++) { if((i&posethb)==i)right&=~powers[i]; } typesize Fright=POSETSIZE(right); typesize SUM=Fleft+Fright; MAP.emplace(poset,SUM); return SUM; } // int main (void) { // Init MAP. MAP.clear();MAP.emplace(0,1);MAP.emplace(1,2); // // fill powers array ************************ for(int i=0;i