#include "binpow.h" #include "sieve.h" #include template struct FixedPowerTable : public std::vector { explicit FixedPowerTable(int n, int k) : std::vector(n) { (*this)[0] = Mod{0}; if (1 < n) { (*this)[1] = Mod{1}; } PrimeGen primes(n); for (int i = 2; i < n; ++i) { auto p = primes.min_div(i); (*this)[i] = p == i ? binpow(Mod{i}, k) : (*this)[i / p] * (*this)[p]; } } };