[clean code] modulo multiplicative inverse using binary exponentiation - easy to understand - c++
concept\nhttps://cp-algorithms.com/algebra/module-inverse.html#finding-the-modular-inverse-for-array-of-numbers-modulo-m\n# Code\n\n#define ll long long\n#defin
# concept\nhttps://cp-algorithms.com/algebra/module-inverse.html#finding-the-modular-inverse-for-array-of-numbers-modulo-m\n# Code\n```\n#define ll long long\n#define mod 1000000007\nconst int N=1e5+1;\nclass Solution {\npublic:\n    ll fact[N];\n\n    void pre(){\n       fact[0]=1;\n       for(int i=1;i<N;i++){\n          fact[i]=(1ll*fact[i-1]*i)%mod;\n       }\n    }\n    \n    ll binexp(int a,int b,int m){\n       int result=1;\n       while(b>0){\n          if(b&1){\n             result=(1ll*result*a)%m;\n          }\n          a=(1ll*a*a)%m;\n          b>>=1;\n       }\n\n       return result;\n    }\n    \n    int countAnagrams(string s) {\n        pre();\n        int i=0;\n        int n=s.length();\n        \n        ll ans=1;\n        while(i<n){\n            vector<int> cnt(26,0);\n            int count=0;\n            ll curr;\n            while(i<n && s[i]!=\' \'){\n                count++;\n                cnt[s[i]-\'a\']++;\n                i++;\n            }\n            curr=fact[count];\n            ll den=1;\n            for(int i=0;i<26;i++) if(cnt[i]>1) den=(den*fact[cnt[i]])%mod;\n\n            curr=(curr*binexp(den,mod-2,mod))%mod;\n            ans=(ans*curr)%mod;\n            i++;\n        }\n        \n        return int(ans%mod);\n    }\n};\n```
['C++']