Open
Conversation
Create LongestPath.cpp
Create TreeXor.cpp
Create TheFamilyTreeOfBob.cpp
Create MaximumSpanningTree.cpp
Create OptimalEdgeWeights.cpp
Create Little Shino and K Ancestor.cpp
Created file Bipartite.cpp
Created file ConecComp.cpp
Created file IsGraphATree.cpp
IsGraphATree.cpp
ConecComp.cpp
Sssp.cpp
Bipartite.cpp
Create program4.cpp
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 todo.cpp
Create multithreading.cpp
Create lowest_common_ancestor.cpp
Create longest_common_subsequence.cpp
Create shortest_distance_bw_cities.cpp
Check anagram
Create file_manipulation_with_C_plus_plus.cpp
Create phonebook.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#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;
}
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";
}