Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BHASKAR'S HACKTOBER.CPP #4

Open
wants to merge 282 commits into
base: master
Choose a base branch
from
Open

Conversation

bhaskar2512
Copy link

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define shazam ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define M 1000000007
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
ll gcd(ll a, ll b) {if (b == 0)return a; return gcd(b, a % b);}
ll power(ll x, ll y, ll p)
{
ll res = 1;
x = x % p;

while (y > 0) {
	if (y & 1)
		res = (res * x) % p;
	y = y >> 1;
	x = (x * x) % p;
}
return res;

}
ll modInverse(ll n, ll p)
{
return power(n, p - 2, p);
}
ll nCr(ll n, ll r, ll p)
{
ll ans = 1;
ll fact[n + 1];
fact[0] = 1;
for (ll i = 1; i <= n; i++)fact[i] = ((fact[i - 1] % p) * (i % p)) % p;
return (((fact[n] * modInverse(fact[n - r], p)) % p) * modInverse(fact[r], p)) % p;
}
int main()
{
shazam;
ll i, j, p, q, t, x, y, z, n, m, k, r;
cin >> n >> r >> p;
cout << nCr(n, r, p) << "\n";
}

sunnyshahabuddin and others added 30 commits October 25, 2020 19:21
Create TheFamilyTreeOfBob.cpp
Create MaximumSpanningTree.cpp
Create OptimalEdgeWeights.cpp
Create Little Shino and K Ancestor.cpp
created file dfs.cpp
Created file Bipartite.cpp
Created file Sssp.cpp
Created file ConecComp.cpp
Created file IsGraphATree.cpp
kumarvivek8 and others added 30 commits October 31, 2022 21:23
Create findingupperboundandlowerbound.cpp
This code defines a simple linked list with two classes, Node and LinkedList. The Node class represents individual elements in the list, and the LinkedList class manages the list and provides methods for appending data and displaying the list.
This code demonstrates the implementation of a Binary Search Tree (BST) in C++.

In-order traversal: 1 2 3 4 5 6 7
In this code:

The HashMap class has a fixed-size array of buckets (in this case, 10 buckets) to store key-value pairs.
The hash method calculates the hash value for a given key using a simple hash function.
The insert method inserts a key-value pair into the hash map, using linear probing to resolve collisions.
The get method retrieves the value associated with a given key.
The remove method removes a key-value pair from the hash map.
The sumOfNaturalNumbers function calculates the sum of the first N natural numbers using a simple loop.

We use the <chrono> library to measure the execution time of the sumOfNaturalNumbers function.

We record the starting time with std::chrono::high_resolution_clock::now() before calling the function and the ending time after the function execution.

We calculate the duration of the operation and print it in microseconds using std::chrono::duration_cast.
Create linked_list_simplified.c++
Create stack_queue_simplified.c++
Create time_taken_code.c++
Create hash_map_simplified.c++
Create bst_simplified.c++
Create lowest_common_ancestor.cpp
Create longest_common_subsequence.cpp
Create shortest_distance_bw_cities.cpp
Create file_manipulation_with_C_plus_plus.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.