巨大数研究 Wiki
Advertisement

以下のプログラム(t.cpp)をc++20でコンパイルしたときに標準出力に出力された値を木数とし、式神巨大数2021のオリジナル部門に投稿します。
t.cpp

#include <algorithm>

#include <iostream>

#include <vector>

using std::vector;



class chainlist {

    int value;

    vector<chainlist> child;



public:

    chainlist(int n = 0) {

        value = n;

    }

    chainlist(vector<chainlist> s, int n = 0) {

        child = s;

        value = n;

    }

    static bool iszero(vector<chainlist> s) {

        return s.empty() || (s.size() == 1 && s.back().value == 0);

    }

    static bool issuccessor(vector<chainlist> s) { return s.empty() ? false : (s.back().value) && (s.back().child.empty() || (s.back().child.size() == 1 && s.back().child.back().value == 0)); }

    vector<chainlist> operator[](size_t n) {

        vector<chainlist> s = child;

        if (s.size()) {

            erase_if(s, [](chainlist s) { return s.value == 0; }), s.end());



            if (s.empty()) {

                goto fin;

            }

            if (issuccessor(s)) {

                s.back().value--;

            } else {

                if (issuccessor(s.back().child)) {

                    s.back().value--;

                    s.push_back(s.back()[n]);

                    s.back().value = n;



                } else {

                    s.back() = chainlist(s.back()[n], s.back().value);

                }

                erase_if(s, [](chainlist s) { return s.value == 0; });

            }

        }

    fin:

        return s;

    }


    void addchild(chainlist n) { child.push_back(n); }

};



chainlist makebiglist(int n, int m) {

    if (n) {

        chainlist l = m;

        l.addchild(makebiglist(n - 1, m));

        return l;

    }

    return m;

}

int f(vector<chainlist> c, int n, int m = 0) {

    if (chainlist::iszero(c)) {

        return n + 1;

    } else {

        if (m == 0) {

            return f(chainlist(c)[n], n, n);

        } else {

            return f(c, f(c, n, m - 1), m - 1);

        }

    }

}

int main() {

    auto big = [](int n) { return f({makebiglist(n, n)}, n); };

    std::cout << big(big(big(big(big(big(big(big(big(big(65536)))))))))) << std::endl;

    return 0;

}
Advertisement