Number of Antisymmetric Relations on a set of N elements | C ++ program for the above approach ; Function to calculate the value of x ^ y % mod in O ( log y ) ; Stores the result of x ^ y ; Update x if it exceeds mod ; If y is odd , then multiply x with result ; Divide y by 2 ; Update the value of x ; Return the resultant value of x ^ y ; Function to count the number of antisymmetric relations in a set consisting of N elements ; Print the count of antisymmetric relations ; Driver Code
#include <iostream> NEW_LINE using namespace std ; const int mod = 1000000007 ; int power ( long long x , unsigned int y ) { int res = 1 ; x = x % mod ; while ( y > 0 ) { if ( y & 1 ) res = ( res * x ) % mod ; y = y >> 1 ; x = ( x * x ) % mod ; } return res ; } int antisymmetricRelation ( int N ) { return ( power ( 2 , N ) * 1LL * power ( 3 , ( N * N - N ) / 2 ) ) % mod ; } int main ( ) { int N = 2 ; cout << antisymmetricRelation ( N ) ; return 0 ; }