Skip to content

Latest commit

 

History

History
31 lines (26 loc) · 622 Bytes

minnonzeroproduct.md

File metadata and controls

31 lines (26 loc) · 622 Bytes

题目描述:

image

解决过程: 没做出来

  • 数论题

代码:

class Solution {
public:
    using ll = long long;
    const int mod = 1e9 + 7;
    int minNonZeroProduct(int p) {
        long long x = (1LL << p) - 1;
        long long y = (1LL << p) - 2;
        long long n = (1LL << (p - 1)) - 1;
        long long res = 1;
        y = y % mod;
        while (n) {
            res = (long long)res * y % mod;
            y = (long long)y * y % mod;
            n = n >> 1;
        }
        return (res * (x % mod)) % mod;
    }
};