# LeetCode - 1969. Minimum Non-Zero Product of the Array Elements ### 題目網址:https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements/ ###### tags: `LeetCode` `Medium` `數學` ```cpp= /* -LeetCode format- Problem: 1969. Minimum Non-Zero Product of the Array Elements Difficulty: Medium by Inversionpeter */ #define MOD 1000000007 int answers[61] = { 0, 1 }; int FastPower(int base, long long power) { int result = 1; while (power) { if (power & 1) result = ((long long)result * base) % MOD; base = ((long long)base * base) % MOD; power >>= 1; } return result; } static const auto Initialize = [] { ios::sync_with_stdio(false); cin.tie(nullptr); for (int i = 2; i <= 60; ++i) answers[i] = ((((1LL << i) - 1) % MOD) * FastPower(((1LL << i) - 2) % MOD, (1LL << (i - 1)) - 1)) % MOD; return nullptr; }(); class Solution { public: int minNonZeroProduct(int p) { return answers[p]; } }; ```