Find the value of the function Y = ( X ^ 6 + X ^ 2 + 9894845 ) % 971 | CPP implementation of above approach ; computing ( a ^ b ) % c ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; long long int modpow ( long long int base , long long int exp , long long int modulus ) { base %= modulus ; long long int result = 1 ; while ( exp > 0 ) { if ( exp & 1 ) result = ( result * base ) % modulus ; base = ( base * base ) % modulus ; exp >>= 1 ; } return result ; } int main ( ) { long long int n = 654654 , mod = 971 ; cout << ( ( ( modpow ( n , 6 , mod ) + modpow ( n , 2 , mod ) ) % mod + 355 ) % mod ) ; return 0 ; }