下面是线段树的代码。 namespace atcoder { int ceil_pow2(int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; } template <class S, S(*op)(S, S), S(*e)()> struct segtree { public: segtree() : segtree(0