The user will give an integer input. I have to find the mod after squaring it. But when I give a big integer, pow()
gives the wrong answer. How can I fix that?
#include<bits/stdc++.h>
using namespace std;
int main()
{
//ios_base:: sync_with_stdio(false);
//cin.tie(NULL);
int t;
cin >> t;
for(int i = 0; i < t; i++)
{
long long n;
cin >> n;
long long sn = 0;
sn = pow(n, 2);
long long v = pow(10, 9) + 7;
cout << sn % v << endl;
}
}