The Answer to Everything

What is the answer to the ultimate question of Life, the universe, and everything? It is You will be…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

@hjr265

Why WA?

#include <bits/stdc++.h>

using namespace std;

int main() {
	long long int t;
	cin>>t;
	while(t--){
		long long int n,k,m;
		cin>>n>>k>>m;
		cout<<(int)pow(sqrt(n)+sqrt(n+1),2*k)%m<<endl;
	}
	return 0;
}

From just a quick look: I see you are using pow(). Shouldn’t you be using an implementation of modpow()? You might want to read about Modular Exponentiation.

If I use modpow() still its giving WA :frowning: