Multiplicative inverse

we have to calculate a^(m-2),in this problem ,what is m here.is it 1000000007.
if yes then why this code is giving wrong answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define mod 1000000005

ll pow(ll a,ll b)
{ ll res=1;
while(b>0)
{
if(b&1)
{
res=resa;
}
a=a
a;
b=b>>1;

}
return res;

}
int main()
{
ll n;
cin>>n;
ll mod =1000000007;
ll x;
x=pow(n,mod-2);
cout<<x<<endl;
return 0;
}

your answer will overflow. Take mod at each step wherever neccesary

Hey you have tried to do so much!
I am unable to get it what have to tried with these 3 functions?!
You just need to do A^(mod-2) for getting inverse.
Do this with fast exponentiation method thats it.

int power(int x, int y, int p)   //x = base, y=MOD-2    p = MOD
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}