Question: Atlassian OA | 4th August 2023
1
Entering edit mode

0
Entering edit mode

can u provide the constraints of question 2

 

ADD COMMENTlink 16 months ago ADARSH RANJAN • 0
0
Entering edit mode

#include <bits/stdc++.h>

using namespace std;

#define int long long

 

int mod = 1e9 + 7;

int power(int x, int y)

{

    int z = 1;

    x = x % mod;

    while (y > 0)

    {

        if (y & 1)

            z = (z * x) % mod;

        y = y >> 1;

        x = (x * x) % mod;

    }

    return z;

}

 

bool isPrime(int n)

{

    for (int i = 2; i * i <= n; ++i)

    {

        if (n % i == 0)

        {

            return false;

        }

    }

    return true;

}

 

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

 

    int n;

    cin >> n;

    int check = (n * (n - 1)) / 2;

    int ans = power(2, check);

    cout << ans << "\n";

    return 0;

}

ADD COMMENTlink 4 months ago Alok Purbey • 10

Login before adding your answer.

Similar Posts
Loading Similar Posts