Documentation for 8b1eab204b

This commit is contained in:
realstealthninja
2024-11-04 12:43:05 +00:00
parent 4fb6e622e9
commit a7bccf7d01
6732 changed files with 153919 additions and 365711 deletions

View File

@@ -1,3 +1,4 @@
<!-- HTML header for doxygen 1.12.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
@@ -5,10 +6,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: math/ncr_modulo_p.cpp File Reference</title>
<title>TheAlgorithms/C++: math/ncr_modulo_p.cpp File Reference</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../navtreedata.js"></script>
@@ -18,14 +24,24 @@
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
<td id="projectalign">
<div id="projectname">Algorithms_in_C++<span id="projectnumber">&#160;1.0.0</span>
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
<div id="projectbrief">All the algorithms implemented in C++</div>
</td>
</tr>
</tbody>
@@ -122,7 +139,9 @@ Include dependency graph for ncr_modulo_p.cpp:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d4/d25/ncr__modulo__p_8cpp__incl.svg" width="252" height="111"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div><table class="memberdecls">
</div>
<p><a href="../../de/dab/ncr__modulo__p_8cpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html">math::ncr_modulo_p::NCRModuloP</a></td></tr>
@@ -160,6 +179,8 @@ Functions</h2></td></tr>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This program aims at calculating <a href="https://cp-algorithms.com/combinatorics/binomial-coefficients.html" target="_blank">nCr modulo p</a>. </p>
<p>nCr is defined as n! / (r! * (n-r)!) where n! represents factorial of n. In many cases, the value of nCr is too large to fit in a 64 bit integer. Hence, in competitive programming, there are many problems or subproblems to compute nCr modulo p where p is a given number. </p><dl class="section author"><dt>Author</dt><dd><a href="https://github.com/KaustubhDamania" target="_blank">Kaustubh Damania</a> </dd></dl>
<p class="definition">Definition in file <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html">ncr_modulo_p.cpp</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="afa2b50f4716fc3b42221a72e676e1422" name="afa2b50f4716fc3b42221a72e676e1422"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afa2b50f4716fc3b42221a72e676e1422">&#9670;&#160;</a></span>example()</h2>
@@ -177,6 +198,8 @@ Functions</h2></td></tr>
</div><div class="memdoc">
<p>example showing the usage of the <a class="el" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html" title="Class which contains all methods required for calculating nCr mod p.">math::ncr_modulo_p::NCRModuloP</a> class </p>
<p class="definition">Definition at line <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00175">175</a> of file <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html">ncr_modulo_p.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 175</span> {</div>
<div class="line"><span class="lineno"> 176</span> <span class="keyword">const</span> int64_t size = 1e6 + 1;</div>
<div class="line"><span class="lineno"> 177</span> <span class="keyword">const</span> int64_t p = 1e9 + 7;</div>
@@ -188,12 +211,11 @@ Functions</h2></td></tr>
<div class="line"><span class="lineno"> 183</span> <span class="comment">// having the ncrObj we can efficiently query the values of (n C r)%p</span></div>
<div class="line"><span class="lineno"> 184</span> <span class="comment">// note that time of the computation does not depend on size</span></div>
<div class="line"><span class="lineno"> 185</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt;= 7; i++) {</div>
<div class="line"><span class="lineno"> 186</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; 6 &lt;&lt; <span class="stringliteral">&quot;C&quot;</span> &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot; mod &quot;</span> &lt;&lt; p &lt;&lt; <span class="stringliteral">&quot; = &quot;</span> &lt;&lt; ncrObj.ncr(6, i)</div>
<div class="line"><span class="lineno"> 186</span> std::cout &lt;&lt; 6 &lt;&lt; <span class="stringliteral">&quot;C&quot;</span> &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot; mod &quot;</span> &lt;&lt; p &lt;&lt; <span class="stringliteral">&quot; = &quot;</span> &lt;&lt; ncrObj.ncr(6, i)</div>
<div class="line"><span class="lineno"> 187</span> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 188</span> }</div>
<div class="line"><span class="lineno"> 189</span>}</div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html">math::ncr_modulo_p::NCRModuloP</a></div><div class="ttdoc">Class which contains all methods required for calculating nCr mod p.</div><div class="ttdef"><b>Definition</b> ncr_modulo_p.cpp:79</div></div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html">math::ncr_modulo_p::NCRModuloP</a></div><div class="ttdoc">Class which contains all methods required for calculating nCr mod p.</div><div class="ttdef"><b>Definition</b> <a href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00079">ncr_modulo_p.cpp:79</a></div></div>
</div><!-- fragment -->
</div>
</div>
@@ -237,6 +259,8 @@ Functions</h2></td></tr>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the gcd of a and b </dd></dl>
<p class="definition">Definition at line <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00044">44</a> of file <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html">ncr_modulo_p.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 45</span> {</div>
<div class="line"><span class="lineno"> 46</span> <span class="keywordflow">if</span> (a == 0) {</div>
<div class="line"><span class="lineno"> 47</span> x = 0;</div>
@@ -251,14 +275,9 @@ Functions</h2></td></tr>
<div class="line"><span class="lineno"> 56</span> y = x1;</div>
<div class="line"><span class="lineno"> 57</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e">gcd</a>;</div>
<div class="line"><span class="lineno"> 58</span>}</div>
<div class="ttc" id="agcd__iterative__euclidean_8cpp_html_ae48807fa2b7000afae599e67f327545e"><div class="ttname"><a href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e">gcd</a></div><div class="ttdeci">int gcd(int num1, int num2)</div><div class="ttdef"><b>Definition</b> gcd_iterative_euclidean.cpp:15</div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_a9010ad5669d31449c3bf3271ab5ebc86"><div class="ttname"><a href="#a9010ad5669d31449c3bf3271ab5ebc86">math::ncr_modulo_p::utils::gcdExtended</a></div><div class="ttdeci">int64_t gcdExtended(const int64_t &amp;a, const int64_t &amp;b, int64_t &amp;x, int64_t &amp;y)</div><div class="ttdoc">finds the values x and y such that a*x + b*y = gcd(a,b)</div><div class="ttdef"><b>Definition</b> ncr_modulo_p.cpp:44</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/dab/ncr__modulo__p_8cpp_a9010ad5669d31449c3bf3271ab5ebc86_cgraph.svg" width="240" height="76"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="agcd__iterative__euclidean_8cpp_html_ae48807fa2b7000afae599e67f327545e"><div class="ttname"><a href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e">gcd</a></div><div class="ttdeci">int gcd(int num1, int num2)</div><div class="ttdef"><b>Definition</b> <a href="../../d4/da0/gcd__iterative__euclidean_8cpp_source.html#l00015">gcd_iterative_euclidean.cpp:15</a></div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_a9010ad5669d31449c3bf3271ab5ebc86"><div class="ttname"><a href="#a9010ad5669d31449c3bf3271ab5ebc86">math::ncr_modulo_p::utils::gcdExtended</a></div><div class="ttdeci">int64_t gcdExtended(const int64_t &amp;a, const int64_t &amp;b, int64_t &amp;x, int64_t &amp;y)</div><div class="ttdoc">finds the values x and y such that a*x + b*y = gcd(a,b)</div><div class="ttdef"><b>Definition</b> <a href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00044">ncr_modulo_p.cpp:44</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
@@ -275,13 +294,15 @@ Here is the call graph for this function:</div>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00191">191</a> of file <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html">ncr_modulo_p.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 191</span> {</div>
<div class="line"><span class="lineno"> 192</span> <a class="code hl_function" href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>();</div>
<div class="line"><span class="lineno"> 193</span> <a class="code hl_function" href="#afa2b50f4716fc3b42221a72e676e1422">example</a>();</div>
<div class="line"><span class="lineno"> 194</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 195</span>}</div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">tests math::ncr_modulo_p::NCRModuloP</div><div class="ttdef"><b>Definition</b> ncr_modulo_p.cpp:142</div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_afa2b50f4716fc3b42221a72e676e1422"><div class="ttname"><a href="#afa2b50f4716fc3b42221a72e676e1422">example</a></div><div class="ttdeci">void example()</div><div class="ttdoc">example showing the usage of the math::ncr_modulo_p::NCRModuloP class</div><div class="ttdef"><b>Definition</b> ncr_modulo_p.cpp:175</div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">tests math::ncr_modulo_p::NCRModuloP</div><div class="ttdef"><b>Definition</b> <a href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00142">ncr_modulo_p.cpp:142</a></div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_afa2b50f4716fc3b42221a72e676e1422"><div class="ttname"><a href="#afa2b50f4716fc3b42221a72e676e1422">example</a></div><div class="ttdeci">void example()</div><div class="ttdoc">example showing the usage of the math::ncr_modulo_p::NCRModuloP class</div><div class="ttdef"><b>Definition</b> <a href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00175">ncr_modulo_p.cpp:175</a></div></div>
</div><!-- fragment -->
</div>
</div>
@@ -312,6 +333,8 @@ Here is the call graph for this function:</div>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the inverce of a modulo m, if it exists, -1 otherwise </dd></dl>
<p class="definition">Definition at line <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00066">66</a> of file <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html">ncr_modulo_p.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 66</span> {</div>
<div class="line"><span class="lineno"> 67</span> int64_t x = 0, y = 0;</div>
<div class="line"><span class="lineno"> 68</span> <span class="keyword">const</span> int64_t <a class="code hl_function" href="../../d4/d18/composite__simpson__rule_8cpp.html#a2f67508d5f392b0321772169342c98ad">g</a> = <a class="code hl_function" href="#a9010ad5669d31449c3bf3271ab5ebc86">gcdExtended</a>(a, m, x, y);</div>
@@ -321,13 +344,8 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 72</span> <span class="keywordflow">return</span> ((x + m) % m);</div>
<div class="line"><span class="lineno"> 73</span> }</div>
<div class="line"><span class="lineno"> 74</span>}</div>
<div class="ttc" id="acomposite__simpson__rule_8cpp_html_a2f67508d5f392b0321772169342c98ad"><div class="ttname"><a href="../../d4/d18/composite__simpson__rule_8cpp.html#a2f67508d5f392b0321772169342c98ad">numerical_methods::simpson_method::g</a></div><div class="ttdeci">double g(double x)</div><div class="ttdoc">Another test function.</div><div class="ttdef"><b>Definition</b> composite_simpson_rule.cpp:115</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/dab/ncr__modulo__p_8cpp_a6c7bfe3bdaa086d32261a5c5584d0fa9_cgraph.svg" width="428" height="76"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="acomposite__simpson__rule_8cpp_html_a2f67508d5f392b0321772169342c98ad"><div class="ttname"><a href="../../d4/d18/composite__simpson__rule_8cpp.html#a2f67508d5f392b0321772169342c98ad">numerical_methods::simpson_method::g</a></div><div class="ttdeci">double g(double x)</div><div class="ttdoc">Another test function.</div><div class="ttdef"><b>Definition</b> <a href="../../d4/d18/composite__simpson__rule_8cpp_source.html#l00115">composite_simpson_rule.cpp:115</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a483bb8ccf42aaf7375a83e91490eda1e" name="a483bb8ccf42aaf7375a83e91490eda1e"></a>
@@ -354,6 +372,8 @@ Here is the call graph for this function:</div>
</div><div class="memdoc">
<p>tests <a class="el" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html" title="Class which contains all methods required for calculating nCr mod p.">math::ncr_modulo_p::NCRModuloP</a> </p>
<p class="definition">Definition at line <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00142">142</a> of file <a class="el" href="../../de/dab/ncr__modulo__p_8cpp_source.html">ncr_modulo_p.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 142</span> {</div>
<div class="line"><span class="lineno"> 143</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a> {</div>
<div class="line"><span class="lineno"> 144</span> <span class="keyword">const</span> int64_t size;</div>
@@ -366,7 +386,7 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 151</span> <span class="keyword">const</span> int64_t r, <span class="keyword">const</span> int64_t expected)</div>
<div class="line"><span class="lineno"> 152</span> : size(size), p(p), n(n), r(r), expected(expected) {}</div>
<div class="line"><span class="lineno"> 153</span> };</div>
<div class="line"><span class="lineno"> 154</span> <span class="keyword">const</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector&lt;TestCase&gt;</a> test_cases = {</div>
<div class="line"><span class="lineno"> 154</span> <span class="keyword">const</span> std::vector&lt;TestCase&gt; test_cases = {</div>
<div class="line"><span class="lineno"> 155</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(60000, 1000000007, 52323, 26161, 224944353),</div>
<div class="line"><span class="lineno"> 156</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(20, 5, 6, 2, 30 % 5),</div>
<div class="line"><span class="lineno"> 157</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(100, 29, 7, 3, 35 % 29),</div>
@@ -381,17 +401,11 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 166</span> tc.expected);</div>
<div class="line"><span class="lineno"> 167</span> }</div>
<div class="line"><span class="lineno"> 168</span> </div>
<div class="line"><span class="lineno"> 169</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;\n\nAll tests have successfully passed!\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 169</span> std::cout &lt;&lt; <span class="stringliteral">&quot;\n\nAll tests have successfully passed!\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 170</span>}</div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html_a499df7a01bcd348345dc5a0ab79bb0e9"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9">math::ncr_modulo_p::NCRModuloP::ncr</a></div><div class="ttdeci">int64_t ncr(const int64_t &amp;n, const int64_t &amp;r) const</div><div class="ttdoc">computes nCr % p</div><div class="ttdef"><b>Definition</b> ncr_modulo_p.cpp:116</div></div>
<div class="ttc" id="astruct_test_case_html"><div class="ttname"><a href="../../da/d86/struct_test_case.html">TestCase</a></div><div class="ttdoc">represents single example inputs and expected output of the function longest_common_string_length</div><div class="ttdef"><b>Definition</b> longest_common_string.cpp:54</div></div>
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/dab/ncr__modulo__p_8cpp_a483bb8ccf42aaf7375a83e91490eda1e_cgraph.svg" width="248" height="52"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html_a499df7a01bcd348345dc5a0ab79bb0e9"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9">math::ncr_modulo_p::NCRModuloP::ncr</a></div><div class="ttdeci">int64_t ncr(const int64_t &amp;n, const int64_t &amp;r) const</div><div class="ttdoc">computes nCr % p</div><div class="ttdef"><b>Definition</b> <a href="../../de/dab/ncr__modulo__p_8cpp_source.html#l00116">ncr_modulo_p.cpp:116</a></div></div>
<div class="ttc" id="astruct_test_case_html"><div class="ttname"><a href="../../da/d86/struct_test_case.html">TestCase</a></div><div class="ttdoc">represents single example inputs and expected output of the function longest_common_string_length</div><div class="ttdef"><b>Definition</b> <a href="../../da/d0d/longest__common__string_8cpp_source.html#l00054">longest_common_string.cpp:54</a></div></div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->

View File

@@ -1,5 +0,0 @@
<map id="tests" name="tests">
<area shape="rect" id="Node000001" title="tests math::ncr_modulo_p::NCRModuloP" alt="" coords="5,13,56,38"/>
<area shape="rect" id="Node000002" href="$d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9" title="computes nCr % p" alt="" coords="104,5,243,46"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="56,23,88,23,88,28,56,28"/>
</map>

View File

@@ -1 +0,0 @@
ec67b7f0511b8bc24ff7b08d968d95ab

View File

@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: tests Pages: 1 -->
<svg width="186pt" height="39pt"
viewBox="0.00 0.00 186.25 38.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
<style type="text/css"><![CDATA[
.node, .edge {opacity: 0.7;}
.node.selected, .edge.selected {opacity: 1;}
.edge:hover path { stroke: red; }
.edge:hover polygon { stroke: red; fill: red; }
]]></style>
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
<svg id="graph" class="graph">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 34.5)">
<title>tests</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="tests math::ncr_modulo_p::NCRModuloP">
<polygon fill="#999999" stroke="#666666" points="37.75,-24.88 0,-24.88 0,-5.63 37.75,-5.63 37.75,-24.88"/>
<text text-anchor="middle" x="18.88" y="-11.38" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9" target="_top" xlink:title="computes nCr % p">
<polygon fill="white" stroke="#666666" points="178.25,-30.5 73.75,-30.5 73.75,0 178.25,0 178.25,-30.5"/>
<text text-anchor="start" x="81.75" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">math::ncr_modulo_p</text>
<text text-anchor="middle" x="126" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::NCRModuloP::ncr</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M38.19,-15.25C45.14,-15.25 53.5,-15.25 62.25,-15.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.96,-18.75 71.96,-15.25 61.96,-11.75 61.96,-18.75"/>
</a>
</g>
</g>
</g>
</svg>
</svg>
<style type='text/css'>
<![CDATA[
[data-mouse-over-selected='false'] { opacity: 0.7; }
[data-mouse-over-selected='true'] { opacity: 1.0; }
]]>
</style>
<script type="application/ecmascript"><![CDATA[
document.addEventListener('DOMContentLoaded', (event) => {
highlightEdges();
highlightAdjacentNodes();
});
]]></script>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: tests Pages: 1 -->
<svg width="186pt" height="39pt"
viewBox="0.00 0.00 186.25 38.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 34.5)">
<title>tests</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="tests math::ncr_modulo_p::NCRModuloP">
<polygon fill="#999999" stroke="#666666" points="37.75,-24.88 0,-24.88 0,-5.63 37.75,-5.63 37.75,-24.88"/>
<text text-anchor="middle" x="18.88" y="-11.38" font-family="Helvetica,sans-Serif" font-size="10.00">tests</text>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9" target="_top" xlink:title="computes nCr % p">
<polygon fill="white" stroke="#666666" points="178.25,-30.5 73.75,-30.5 73.75,0 178.25,0 178.25,-30.5"/>
<text text-anchor="start" x="81.75" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">math::ncr_modulo_p</text>
<text text-anchor="middle" x="126" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::NCRModuloP::ncr</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M38.19,-15.25C45.14,-15.25 53.5,-15.25 62.25,-15.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.96,-18.75 71.96,-15.25 61.96,-11.75 61.96,-18.75"/>
</a>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -1,9 +0,0 @@
<map id="math::ncr_modulo_p::utils::modInverse" name="math::ncr_modulo_p::utils::modInverse">
<area shape="rect" id="Node000001" title=" " alt="" coords="5,29,145,70"/>
<area shape="poly" id="edge4_Node000001_Node000001" title=" " alt="" coords="39,29,37,19,43,10,56,5,75,3,95,5,108,11,105,16,94,10,75,8,57,10,47,15,43,20,44,28"/>
<area shape="rect" id="Node000002" href="$de/dab/ncr__modulo__p_8cpp.html#a9010ad5669d31449c3bf3271ab5ebc86" title="finds the values x and y such that a*x + b*y = gcd(a,b)" alt="" coords="193,29,332,70"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="145,47,177,47,177,52,145,52"/>
<area shape="poly" id="edge3_Node000002_Node000002" title=" " alt="" coords="235,29,234,20,238,11,248,5,262,3,278,5,287,12,284,16,276,10,262,8,250,10,242,14,239,20,240,28"/>
<area shape="rect" id="Node000003" href="$d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e" title=" " alt="" coords="380,37,422,62"/>
<area shape="poly" id="edge2_Node000002_Node000003" title=" " alt="" coords="333,47,364,47,364,52,333,52"/>
</map>

View File

@@ -1 +0,0 @@
1a4f0a265ffd31483084966d366feec6

View File

@@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: math::ncr_modulo_p::utils::modInverse Pages: 1 -->
<svg width="321pt" height="57pt"
viewBox="0.00 0.00 320.75 56.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
<style type="text/css"><![CDATA[
.node, .edge {opacity: 0.7;}
.node.selected, .edge.selected {opacity: 1;}
.edge:hover path { stroke: red; }
.edge:hover polygon { stroke: red; fill: red; }
]]></style>
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
<svg id="graph" class="graph">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 52.5)">
<title>math::ncr_modulo_p::utils::modInverse</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title=" ">
<polygon fill="#999999" stroke="#666666" points="104.5,-30.5 0,-30.5 0,0 104.5,0 104.5,-30.5"/>
<text text-anchor="start" x="8" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">math::ncr_modulo_p</text>
<text text-anchor="middle" x="52.25" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::utils::modInverse</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node1 -->
<g id="edge4_Node000001_Node000001" class="edge">
<title>Node1&#45;&gt;Node1</title>
<g id="a_edge4_Node000001_Node000001"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M27.35,-30.99C22.27,-40.06 30.57,-48.5 52.25,-48.5 64.11,-48.5 71.96,-45.97 75.81,-42.2"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="79.26,-42.83 76.97,-32.49 72.31,-42.01 79.26,-42.83"/>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../de/dab/ncr__modulo__p_8cpp.html#a9010ad5669d31449c3bf3271ab5ebc86" target="_top" xlink:title="finds the values x and y such that a*x + b*y = gcd(a,b)">
<polygon fill="white" stroke="#666666" points="245,-30.5 140.5,-30.5 140.5,0 245,0 245,-30.5"/>
<text text-anchor="start" x="148.5" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">math::ncr_modulo_p</text>
<text text-anchor="middle" x="192.75" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::utils::gcdExtended</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M104.82,-15.25C112.66,-15.25 120.83,-15.25 128.88,-15.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="128.62,-18.75 138.62,-15.25 128.62,-11.75 128.62,-18.75"/>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node2 -->
<g id="edge3_Node000002_Node000002" class="edge">
<title>Node2&#45;&gt;Node2</title>
<g id="a_edge3_Node000002_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M174.3,-30.99C170.53,-40.06 176.68,-48.5 192.75,-48.5 201.54,-48.5 207.36,-45.97 210.21,-42.2"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="213.68,-42.76 211.07,-32.49 206.7,-42.15 213.68,-42.76"/>
</a>
</g>
</g>
<!-- Node3 -->
<g id="Node000003" class="node">
<title>Node3</title>
<g id="a_Node000003"><a xlink:href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e" target="_top" xlink:title=" ">
<polygon fill="white" stroke="#666666" points="312.75,-24.88 281,-24.88 281,-5.63 312.75,-5.63 312.75,-24.88"/>
<text text-anchor="middle" x="296.88" y="-11.38" font-family="Helvetica,sans-Serif" font-size="10.00">gcd</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node3 -->
<g id="edge2_Node000002_Node000003" class="edge">
<title>Node2&#45;&gt;Node3</title>
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M245.41,-15.25C253.65,-15.25 261.87,-15.25 269.21,-15.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="269.07,-18.75 279.07,-15.25 269.07,-11.75 269.07,-18.75"/>
</a>
</g>
</g>
</g>
</svg>
</svg>
<style type='text/css'>
<![CDATA[
[data-mouse-over-selected='false'] { opacity: 0.7; }
[data-mouse-over-selected='true'] { opacity: 1.0; }
]]>
</style>
<script type="application/ecmascript"><![CDATA[
document.addEventListener('DOMContentLoaded', (event) => {
highlightEdges();
highlightAdjacentNodes();
});
]]></script>
</svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: math::ncr_modulo_p::utils::modInverse Pages: 1 -->
<svg width="321pt" height="57pt"
viewBox="0.00 0.00 320.75 56.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 52.5)">
<title>math::ncr_modulo_p::utils::modInverse</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title=" ">
<polygon fill="#999999" stroke="#666666" points="104.5,-30.5 0,-30.5 0,0 104.5,0 104.5,-30.5"/>
<text text-anchor="start" x="8" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">math::ncr_modulo_p</text>
<text text-anchor="middle" x="52.25" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::utils::modInverse</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node1 -->
<g id="edge4_Node000001_Node000001" class="edge">
<title>Node1&#45;&gt;Node1</title>
<g id="a_edge4_Node000001_Node000001"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M27.35,-30.99C22.27,-40.06 30.57,-48.5 52.25,-48.5 64.11,-48.5 71.96,-45.97 75.81,-42.2"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="79.26,-42.83 76.97,-32.49 72.31,-42.01 79.26,-42.83"/>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../de/dab/ncr__modulo__p_8cpp.html#a9010ad5669d31449c3bf3271ab5ebc86" target="_top" xlink:title="finds the values x and y such that a*x + b*y = gcd(a,b)">
<polygon fill="white" stroke="#666666" points="245,-30.5 140.5,-30.5 140.5,0 245,0 245,-30.5"/>
<text text-anchor="start" x="148.5" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">math::ncr_modulo_p</text>
<text text-anchor="middle" x="192.75" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::utils::gcdExtended</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M104.82,-15.25C112.66,-15.25 120.83,-15.25 128.88,-15.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="128.62,-18.75 138.62,-15.25 128.62,-11.75 128.62,-18.75"/>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node2 -->
<g id="edge3_Node000002_Node000002" class="edge">
<title>Node2&#45;&gt;Node2</title>
<g id="a_edge3_Node000002_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M174.3,-30.99C170.53,-40.06 176.68,-48.5 192.75,-48.5 201.54,-48.5 207.36,-45.97 210.21,-42.2"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="213.68,-42.76 211.07,-32.49 206.7,-42.15 213.68,-42.76"/>
</a>
</g>
</g>
<!-- Node3 -->
<g id="Node000003" class="node">
<title>Node3</title>
<g id="a_Node000003"><a xlink:href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e" target="_top" xlink:title=" ">
<polygon fill="white" stroke="#666666" points="312.75,-24.88 281,-24.88 281,-5.63 312.75,-5.63 312.75,-24.88"/>
<text text-anchor="middle" x="296.88" y="-11.38" font-family="Helvetica,sans-Serif" font-size="10.00">gcd</text>
</a>
</g>
</g>
<!-- Node2&#45;&gt;Node3 -->
<g id="edge2_Node000002_Node000003" class="edge">
<title>Node2&#45;&gt;Node3</title>
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M245.41,-15.25C253.65,-15.25 261.87,-15.25 269.21,-15.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="269.07,-18.75 279.07,-15.25 269.07,-11.75 269.07,-18.75"/>
</a>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -1,6 +0,0 @@
<map id="math::ncr_modulo_p::utils::gcdExtended" name="math::ncr_modulo_p::utils::gcdExtended">
<area shape="rect" id="Node000001" title="finds the values x and y such that a*x + b*y = gcd(a,b)" alt="" coords="5,29,145,70"/>
<area shape="poly" id="edge2_Node000001_Node000001" title=" " alt="" coords="48,29,46,20,51,11,61,5,75,3,91,5,100,12,97,16,89,10,75,8,62,10,55,14,52,20,53,28"/>
<area shape="rect" id="Node000002" href="$d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e" title=" " alt="" coords="193,37,235,62"/>
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="145,47,177,47,177,52,145,52"/>
</map>

View File

@@ -1 +0,0 @@
ba3da75994498c1bdb1f6cc36a33fadf

View File

@@ -1,75 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: math::ncr_modulo_p::utils::gcdExtended Pages: 1 -->
<svg width="180pt" height="57pt"
viewBox="0.00 0.00 180.25 56.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
<style type="text/css"><![CDATA[
.node, .edge {opacity: 0.7;}
.node.selected, .edge.selected {opacity: 1;}
.edge:hover path { stroke: red; }
.edge:hover polygon { stroke: red; fill: red; }
]]></style>
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
<svg id="graph" class="graph">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 52.5)">
<title>math::ncr_modulo_p::utils::gcdExtended</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="finds the values x and y such that a*x + b*y = gcd(a,b)">
<polygon fill="#999999" stroke="#666666" points="104.5,-30.5 0,-30.5 0,0 104.5,0 104.5,-30.5"/>
<text text-anchor="start" x="8" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">math::ncr_modulo_p</text>
<text text-anchor="middle" x="52.25" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::utils::gcdExtended</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node1 -->
<g id="edge2_Node000001_Node000001" class="edge">
<title>Node1&#45;&gt;Node1</title>
<g id="a_edge2_Node000001_Node000001"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M33.8,-30.99C30.03,-40.06 36.18,-48.5 52.25,-48.5 61.04,-48.5 66.86,-45.97 69.71,-42.2"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="73.18,-42.76 70.57,-32.49 66.2,-42.15 73.18,-42.76"/>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e" target="_top" xlink:title=" ">
<polygon fill="white" stroke="#666666" points="172.25,-24.88 140.5,-24.88 140.5,-5.63 172.25,-5.63 172.25,-24.88"/>
<text text-anchor="middle" x="156.38" y="-11.38" font-family="Helvetica,sans-Serif" font-size="10.00">gcd</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M104.91,-15.25C113.15,-15.25 121.37,-15.25 128.71,-15.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="128.57,-18.75 138.57,-15.25 128.57,-11.75 128.57,-18.75"/>
</a>
</g>
</g>
</g>
</svg>
</svg>
<style type='text/css'>
<![CDATA[
[data-mouse-over-selected='false'] { opacity: 0.7; }
[data-mouse-over-selected='true'] { opacity: 1.0; }
]]>
</style>
<script type="application/ecmascript"><![CDATA[
document.addEventListener('DOMContentLoaded', (event) => {
highlightEdges();
highlightAdjacentNodes();
});
]]></script>
</svg>

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
-->
<!-- Title: math::ncr_modulo_p::utils::gcdExtended Pages: 1 -->
<svg width="180pt" height="57pt"
viewBox="0.00 0.00 180.25 56.50" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 52.5)">
<title>math::ncr_modulo_p::utils::gcdExtended</title>
<!-- Node1 -->
<g id="Node000001" class="node">
<title>Node1</title>
<g id="a_Node000001"><a xlink:title="finds the values x and y such that a*x + b*y = gcd(a,b)">
<polygon fill="#999999" stroke="#666666" points="104.5,-30.5 0,-30.5 0,0 104.5,0 104.5,-30.5"/>
<text text-anchor="start" x="8" y="-17" font-family="Helvetica,sans-Serif" font-size="10.00">math::ncr_modulo_p</text>
<text text-anchor="middle" x="52.25" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">::utils::gcdExtended</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node1 -->
<g id="edge2_Node000001_Node000001" class="edge">
<title>Node1&#45;&gt;Node1</title>
<g id="a_edge2_Node000001_Node000001"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M33.8,-30.99C30.03,-40.06 36.18,-48.5 52.25,-48.5 61.04,-48.5 66.86,-45.97 69.71,-42.2"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="73.18,-42.76 70.57,-32.49 66.2,-42.15 73.18,-42.76"/>
</a>
</g>
</g>
<!-- Node2 -->
<g id="Node000002" class="node">
<title>Node2</title>
<g id="a_Node000002"><a xlink:href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e" target="_top" xlink:title=" ">
<polygon fill="white" stroke="#666666" points="172.25,-24.88 140.5,-24.88 140.5,-5.63 172.25,-5.63 172.25,-24.88"/>
<text text-anchor="middle" x="156.38" y="-11.38" font-family="Helvetica,sans-Serif" font-size="10.00">gcd</text>
</a>
</g>
</g>
<!-- Node1&#45;&gt;Node2 -->
<g id="edge1_Node000001_Node000002" class="edge">
<title>Node1&#45;&gt;Node2</title>
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
<path fill="none" stroke="#63b8ff" d="M104.91,-15.25C113.15,-15.25 121.37,-15.25 128.71,-15.25"/>
<polygon fill="#63b8ff" stroke="#63b8ff" points="128.57,-18.75 138.57,-15.25 128.57,-11.75 128.57,-18.75"/>
</a>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,297 @@
<!-- HTML header for doxygen 1.12.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TheAlgorithms/C++: math/ncr_modulo_p.cpp Source File</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../navtreedata.js"></script>
<script type="text/javascript" src="../../navtree.js"></script>
<script type="text/javascript" src="../../resize.js"></script>
<script type="text/javascript" src="../../cookie.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
<td id="projectalign">
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">All the algorithms implemented in C++</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(1); });
/* @license-end */
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('de/dab/ncr__modulo__p_8cpp_source.html','../../'); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">ncr_modulo_p.cpp</div></div>
</div><!--header-->
<div class="contents">
<a href="../../de/dab/ncr__modulo__p_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="preprocessor">#include &lt;cassert&gt;</span> </div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="preprocessor">#include &lt;iostream&gt;</span> </div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="preprocessor">#include &lt;vector&gt;</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> </div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../dd/d47/namespacemath.html">math</a> {</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../d4/db9/namespacencr__modulo__p.html">ncr_modulo_p</a> {</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> </div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../d6/d84/namespaceutils.html">utils</a> {</div>
<div class="foldopen" id="foldopen00044" data-start="{" data-end="}">
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"><a class="line" href="../../de/dab/ncr__modulo__p_8cpp.html#a9010ad5669d31449c3bf3271ab5ebc86"> 44</a></span>int64_t <a class="code hl_function" href="../../de/dab/ncr__modulo__p_8cpp.html#a9010ad5669d31449c3bf3271ab5ebc86">gcdExtended</a>(<span class="keyword">const</span> int64_t&amp; a, <span class="keyword">const</span> int64_t&amp; b, int64_t&amp; x,</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> int64_t&amp; y) {</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> <span class="keywordflow">if</span> (a == 0) {</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> x = 0;</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> y = 1;</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordflow">return</span> b;</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> }</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> </div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> int64_t x1 = 0, y1 = 0;</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <span class="keyword">const</span> int64_t <a class="code hl_function" href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e">gcd</a> = <a class="code hl_function" href="../../de/dab/ncr__modulo__p_8cpp.html#a9010ad5669d31449c3bf3271ab5ebc86">gcdExtended</a>(b % a, a, x1, y1);</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> </div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> x = y1 - (b / a) * x1;</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> y = x1;</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e">gcd</a>;</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span>}</div>
</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> </div>
<div class="foldopen" id="foldopen00066" data-start="{" data-end="}">
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"><a class="line" href="../../de/dab/ncr__modulo__p_8cpp.html#a6c7bfe3bdaa086d32261a5c5584d0fa9"> 66</a></span>int64_t <a class="code hl_function" href="../../de/dab/ncr__modulo__p_8cpp.html#a6c7bfe3bdaa086d32261a5c5584d0fa9">modInverse</a>(<span class="keyword">const</span> int64_t&amp; a, <span class="keyword">const</span> int64_t&amp; m) {</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> int64_t x = 0, y = 0;</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="keyword">const</span> int64_t g = <a class="code hl_function" href="../../de/dab/ncr__modulo__p_8cpp.html#a9010ad5669d31449c3bf3271ab5ebc86">gcdExtended</a>(a, m, x, y);</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <span class="keywordflow">if</span> (g != 1) { <span class="comment">// modular inverse doesn&#39;t exist</span></div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <span class="keywordflow">return</span> -1;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <span class="keywordflow">return</span> ((x + m) % m);</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> }</div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span>}</div>
</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span>} <span class="comment">// namespace utils</span></div>
<div class="foldopen" id="foldopen00079" data-start="{" data-end="};">
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"><a class="line" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html"> 79</a></span><span class="keyword">class </span><a class="code hl_class" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html">NCRModuloP</a> {</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="keyword">private</span>:</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <span class="keyword">const</span> int64_t p = 0; </div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <span class="keyword">const</span> std::vector&lt;int64_t&gt;</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"><a class="line" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a738a5f59bb3560c81cdb7f43bcfe9fec"> 83</a></span> <a class="code hl_variable" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a738a5f59bb3560c81cdb7f43bcfe9fec">fac</a>; </div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> </div>
<div class="foldopen" id="foldopen00092" data-start="{" data-end="}">
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"><a class="line" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#ab5744fa589f6a48f9fe7bca13dbe661f"> 92</a></span> <span class="keyword">static</span> std::vector&lt;int64_t&gt; <a class="code hl_function" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#ab5744fa589f6a48f9fe7bca13dbe661f">computeFactorialsMod</a>(<span class="keyword">const</span> int64_t&amp; max_arg_val,</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> <span class="keyword">const</span> int64_t&amp; mod) {</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"> 94</span> <span class="keyword">auto</span> res = std::vector&lt;int64_t&gt;(max_arg_val + 1);</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> res[0] = 1;</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="keywordflow">for</span> (int64_t i = 1; i &lt;= max_arg_val; i++) {</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> res[i] = (res[i - 1] * i) % mod;</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> }</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> <span class="keywordflow">return</span> res;</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> }</div>
</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> </div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> <span class="keyword">public</span>:</div>
<div class="foldopen" id="foldopen00107" data-start="{" data-end="}">
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"><a class="line" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a94b07e7dc61d8d7a1e9c5a28988e72f9"> 107</a></span> <a class="code hl_function" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a94b07e7dc61d8d7a1e9c5a28988e72f9">NCRModuloP</a>(<span class="keyword">const</span> int64_t&amp; size, <span class="keyword">const</span> int64_t&amp; p)</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> : p(p), <a class="code hl_variable" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a738a5f59bb3560c81cdb7f43bcfe9fec">fac</a>(<a class="code hl_function" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#ab5744fa589f6a48f9fe7bca13dbe661f">computeFactorialsMod</a>(size, p)) {}</div>
</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> </div>
<div class="foldopen" id="foldopen00116" data-start="{" data-end="}">
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"><a class="line" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9"> 116</a></span> int64_t <a class="code hl_function" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9">ncr</a>(<span class="keyword">const</span> int64_t&amp; n, <span class="keyword">const</span> int64_t&amp; r)<span class="keyword"> const </span>{</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> <span class="comment">// Base cases</span></div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <span class="keywordflow">if</span> (r &gt; n) {</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> }</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <span class="keywordflow">if</span> (r == 1) {</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> <span class="keywordflow">return</span> n % p;</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> }</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> <span class="keywordflow">if</span> (r == 0 || r == n) {</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <span class="keywordflow">return</span> 1;</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> }</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <span class="comment">// fac is a global array with fac[r] = (r! % p)</span></div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> <span class="keyword">const</span> <span class="keyword">auto</span> denominator = (<a class="code hl_variable" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a738a5f59bb3560c81cdb7f43bcfe9fec">fac</a>[r] * <a class="code hl_variable" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a738a5f59bb3560c81cdb7f43bcfe9fec">fac</a>[n - r]) % p;</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="keyword">const</span> <span class="keyword">auto</span> denominator_inv = utils::modInverse(denominator, p);</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> <span class="keywordflow">if</span> (denominator_inv &lt; 0) { <span class="comment">// modular inverse doesn&#39;t exist</span></div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> <span class="keywordflow">return</span> -1;</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> }</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> <span class="keywordflow">return</span> (<a class="code hl_variable" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a738a5f59bb3560c81cdb7f43bcfe9fec">fac</a>[n] * denominator_inv) % p;</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> }</div>
</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span>};</div>
</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span>} <span class="comment">// namespace ncr_modulo_p</span></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span>} <span class="comment">// namespace math</span></div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> </div>
<div class="foldopen" id="foldopen00142" data-start="{" data-end="}">
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"><a class="line" href="../../de/dab/ncr__modulo__p_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e"> 142</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../de/dab/ncr__modulo__p_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>() {</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> <span class="keyword">struct </span><a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a> {</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> <span class="keyword">const</span> int64_t size;</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> <span class="keyword">const</span> int64_t p;</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> <span class="keyword">const</span> int64_t n;</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> <span class="keyword">const</span> int64_t r;</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> <span class="keyword">const</span> int64_t expected;</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> </div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(<span class="keyword">const</span> int64_t size, <span class="keyword">const</span> int64_t p, <span class="keyword">const</span> int64_t n,</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> <span class="keyword">const</span> int64_t r, <span class="keyword">const</span> int64_t expected)</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> : size(size), p(p), n(n), r(r), expected(expected) {}</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> };</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> <span class="keyword">const</span> std::vector&lt;TestCase&gt; test_cases = {</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(60000, 1000000007, 52323, 26161, 224944353),</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(20, 5, 6, 2, 30 % 5),</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(100, 29, 7, 3, 35 % 29),</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(1000, 13, 10, 3, 120 % 13),</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(20, 17, 1, 10, 0),</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(45, 19, 23, 1, 23 % 19),</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(45, 19, 23, 0, 1),</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(45, 19, 23, 23, 1),</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> <a class="code hl_struct" href="../../da/d86/struct_test_case.html">TestCase</a>(20, 9, 10, 2, -1)};</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span>&amp; tc : test_cases) {</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> assert(<a class="code hl_class" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html">math::ncr_modulo_p::NCRModuloP</a>(tc.size, tc.p).<a class="code hl_function" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9">ncr</a>(tc.n, tc.r) ==</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> tc.expected);</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> }</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> </div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> std::cout &lt;&lt; <span class="stringliteral">&quot;\n\nAll tests have successfully passed!\n&quot;</span>;</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span>}</div>
</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> </div>
<div class="foldopen" id="foldopen00175" data-start="{" data-end="}">
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"><a class="line" href="../../de/dab/ncr__modulo__p_8cpp.html#afa2b50f4716fc3b42221a72e676e1422"> 175</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="../../de/dab/ncr__modulo__p_8cpp.html#afa2b50f4716fc3b42221a72e676e1422">example</a>() {</div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> <span class="keyword">const</span> int64_t size = 1e6 + 1;</div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"> 177</span> <span class="keyword">const</span> int64_t p = 1e9 + 7;</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> </div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> <span class="comment">// the ncrObj contains the precomputed values of factorials modulo p for</span></div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span> <span class="comment">// values from 0 to size</span></div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno"> 181</span> <span class="keyword">const</span> <span class="keyword">auto</span> ncrObj = <a class="code hl_class" href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html">math::ncr_modulo_p::NCRModuloP</a>(size, p);</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno"> 182</span> </div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno"> 183</span> <span class="comment">// having the ncrObj we can efficiently query the values of (n C r)%p</span></div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno"> 184</span> <span class="comment">// note that time of the computation does not depend on size</span></div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt;= 7; i++) {</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno"> 186</span> std::cout &lt;&lt; 6 &lt;&lt; <span class="stringliteral">&quot;C&quot;</span> &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot; mod &quot;</span> &lt;&lt; p &lt;&lt; <span class="stringliteral">&quot; = &quot;</span> &lt;&lt; ncrObj.ncr(6, i)</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> }</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"> 189</span>}</div>
</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> </div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span><span class="keywordtype">int</span> <a class="code hl_function" href="../../dd/d1e/generate__parentheses_8cpp.html#gae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span> <a class="code hl_function" href="../../de/dab/ncr__modulo__p_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>();</div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno"> 193</span> <a class="code hl_function" href="../../de/dab/ncr__modulo__p_8cpp.html#afa2b50f4716fc3b42221a72e676e1422">example</a>();</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno"> 194</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno"> 195</span>}</div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html">math::ncr_modulo_p::NCRModuloP</a></div><div class="ttdoc">Class which contains all methods required for calculating nCr mod p.</div><div class="ttdef"><b>Definition</b> <a href="#l00079">ncr_modulo_p.cpp:79</a></div></div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html_a499df7a01bcd348345dc5a0ab79bb0e9"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a499df7a01bcd348345dc5a0ab79bb0e9">math::ncr_modulo_p::NCRModuloP::ncr</a></div><div class="ttdeci">int64_t ncr(const int64_t &amp;n, const int64_t &amp;r) const</div><div class="ttdoc">computes nCr % p</div><div class="ttdef"><b>Definition</b> <a href="#l00116">ncr_modulo_p.cpp:116</a></div></div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html_a738a5f59bb3560c81cdb7f43bcfe9fec"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a738a5f59bb3560c81cdb7f43bcfe9fec">math::ncr_modulo_p::NCRModuloP::fac</a></div><div class="ttdeci">const std::vector&lt; int64_t &gt; fac</div><div class="ttdoc">the p from (nCr % p)</div><div class="ttdef"><b>Definition</b> <a href="#l00083">ncr_modulo_p.cpp:83</a></div></div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html_a94b07e7dc61d8d7a1e9c5a28988e72f9"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#a94b07e7dc61d8d7a1e9c5a28988e72f9">math::ncr_modulo_p::NCRModuloP::NCRModuloP</a></div><div class="ttdeci">NCRModuloP(const int64_t &amp;size, const int64_t &amp;p)</div><div class="ttdoc">constructs an NCRModuloP object allowing to compute (nCr)p for inputs from 0 to size</div><div class="ttdef"><b>Definition</b> <a href="#l00107">ncr_modulo_p.cpp:107</a></div></div>
<div class="ttc" id="aclassmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p_html_ab5744fa589f6a48f9fe7bca13dbe661f"><div class="ttname"><a href="../../d6/dc1/classmath_1_1ncr__modulo__p_1_1_n_c_r_modulo_p.html#ab5744fa589f6a48f9fe7bca13dbe661f">math::ncr_modulo_p::NCRModuloP::computeFactorialsMod</a></div><div class="ttdeci">static std::vector&lt; int64_t &gt; computeFactorialsMod(const int64_t &amp;max_arg_val, const int64_t &amp;mod)</div><div class="ttdoc">stores precomputed factorial(i) % p value</div><div class="ttdef"><b>Definition</b> <a href="#l00092">ncr_modulo_p.cpp:92</a></div></div>
<div class="ttc" id="agcd__iterative__euclidean_8cpp_html_ae48807fa2b7000afae599e67f327545e"><div class="ttname"><a href="../../d4/da0/gcd__iterative__euclidean_8cpp.html#ae48807fa2b7000afae599e67f327545e">gcd</a></div><div class="ttdeci">int gcd(int num1, int num2)</div><div class="ttdef"><b>Definition</b> <a href="../../d4/da0/gcd__iterative__euclidean_8cpp_source.html#l00015">gcd_iterative_euclidean.cpp:15</a></div></div>
<div class="ttc" id="agenerate__parentheses_8cpp_html_gae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../dd/d1e/generate__parentheses_8cpp.html#gae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdoc">Main function.</div><div class="ttdef"><b>Definition</b> <a href="../../dd/d1e/generate__parentheses_8cpp_source.html#l00110">generate_parentheses.cpp:110</a></div></div>
<div class="ttc" id="anamespacemath_html"><div class="ttname"><a href="../../dd/d47/namespacemath.html">math</a></div><div class="ttdoc">for assert</div></div>
<div class="ttc" id="anamespacencr__modulo__p_html"><div class="ttname"><a href="../../d4/db9/namespacencr__modulo__p.html">ncr_modulo_p</a></div><div class="ttdoc">Functions for nCr modulo p implementation.</div></div>
<div class="ttc" id="anamespaceutils_html"><div class="ttname"><a href="../../d6/d84/namespaceutils.html">utils</a></div><div class="ttdoc">this namespace contains the definitions of the functions called from the class math::ncr_modulo_p::NC...</div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_a483bb8ccf42aaf7375a83e91490eda1e"><div class="ttname"><a href="../../de/dab/ncr__modulo__p_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a></div><div class="ttdeci">static void tests()</div><div class="ttdoc">tests math::ncr_modulo_p::NCRModuloP</div><div class="ttdef"><b>Definition</b> <a href="#l00142">ncr_modulo_p.cpp:142</a></div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_a6c7bfe3bdaa086d32261a5c5584d0fa9"><div class="ttname"><a href="../../de/dab/ncr__modulo__p_8cpp.html#a6c7bfe3bdaa086d32261a5c5584d0fa9">math::ncr_modulo_p::utils::modInverse</a></div><div class="ttdeci">int64_t modInverse(const int64_t &amp;a, const int64_t &amp;m)</div><div class="ttdef"><b>Definition</b> <a href="#l00066">ncr_modulo_p.cpp:66</a></div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_a9010ad5669d31449c3bf3271ab5ebc86"><div class="ttname"><a href="../../de/dab/ncr__modulo__p_8cpp.html#a9010ad5669d31449c3bf3271ab5ebc86">math::ncr_modulo_p::utils::gcdExtended</a></div><div class="ttdeci">int64_t gcdExtended(const int64_t &amp;a, const int64_t &amp;b, int64_t &amp;x, int64_t &amp;y)</div><div class="ttdoc">finds the values x and y such that a*x + b*y = gcd(a,b)</div><div class="ttdef"><b>Definition</b> <a href="#l00044">ncr_modulo_p.cpp:44</a></div></div>
<div class="ttc" id="ancr__modulo__p_8cpp_html_afa2b50f4716fc3b42221a72e676e1422"><div class="ttname"><a href="../../de/dab/ncr__modulo__p_8cpp.html#afa2b50f4716fc3b42221a72e676e1422">example</a></div><div class="ttdeci">void example()</div><div class="ttdoc">example showing the usage of the math::ncr_modulo_p::NCRModuloP class</div><div class="ttdef"><b>Definition</b> <a href="#l00175">ncr_modulo_p.cpp:175</a></div></div>
<div class="ttc" id="astruct_test_case_html"><div class="ttname"><a href="../../da/d86/struct_test_case.html">TestCase</a></div><div class="ttdoc">represents single example inputs and expected output of the function longest_common_string_length</div><div class="ttdef"><b>Definition</b> <a href="../../da/d0d/longest__common__string_8cpp_source.html#l00054">longest_common_string.cpp:54</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="../../dir_296d53ceaeaa7e099814a6def439fe8a.html">math</a></li><li class="navelem"><a class="el" href="../../de/dab/ncr__modulo__p_8cpp.html">ncr_modulo_p.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0 </li>
</ul>
</div>
</body>
</html>