# Sereja and GCD (SEAGCD)

below is my code -

#define S(x) scanf("%d", &x)
#define SS(x) scanf("%s", &x)
#define MOD 1000000007

using namespace std;

void input() {
#ifndef ONLINE_JUDGE
freopen(“C:\Users\ronish\OneDrive\Documents\in.txt”,“r”,stdin);
#endif
}

int f;

int pow(int base,int exp){
int ans=1;
while(exp){
if(exp 2) ans = (long long)ans * base MOD;
base = (long long)base * base % MOD;
exp /= 2;
}
if(ans < 0) ans += MOD;
return ans;
}

int main(int argc, char const *argv[])
{
input();
int t;
cin >> t;
while (t–) {
int n, m, l, r;
cin >> n >> m >> l >> r;
int ans = 0;
for (int k = l; k <= r; ++k)
{
f[k] = 0;
}
for (int i = l; i <= r; ++i)
{
if (f[i]) continue;
int x = r / i;
int y = m / i;
int z = y - x;
for (int k = i; k <= i * x; k = k + i) f[k] = 1;
ans = ans + pow(x, n);
if (ans < 0) ans = ans + MOD;
if (ans > MOD) ans = ans % MOD;
}
cout << ans << endl;
}
return 0;
}
my logic - Instead of finding arrays with HCF exactly equal to i, I m finding arrays with HCF equals i or multiple of i b/w i to R.
I m not getting why m i getting wrong ans can anyone help?