nikunjsoni

1969

Aug 15th, 2021
915
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution {
  2. public:
  3.     typedef long long ll;
  4.     ll mod = 1000000007LL;
  5.    
  6.     int minNonZeroProduct(int p) {
  7.         ll n = (1LL<<p)-1LL;
  8.         ll prod = n;
  9.         prod = prod%mod;
  10.         prod = (prod*fpow(n-1, n/2))%mod;
  11.         return prod;
  12.     }
  13.    
  14.     ll fpow(ll x, ll y) {
  15.         ll r = 1;
  16.         x = x%mod;
  17.         while(y > 0){
  18.             if(y & 1)
  19.                 r = (r * x) % mod;
  20.             y >>= 1;  x = (x * x) % mod;
  21.         }
  22.         return r%mod;
  23.     }
  24. };
RAW Paste Data