<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=1011_-_p3factoriale</id>
	<title>1011 - p3factoriale - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=1011_-_p3factoriale"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=1011_-_p3factoriale&amp;action=history"/>
	<updated>2026-05-01T03:40:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=1011_-_p3factoriale&amp;diff=10107&amp;oldid=prev</id>
		<title>Danciu: Pagină nouă:  = Cerința = Se dau &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt; și &lt;code&gt;p&lt;/code&gt; numere naturale, astfel încât &lt;code&gt;a ≥ b + c&lt;/code&gt; și &lt;code&gt;p&lt;/code&gt; număr prim. Să se afle dacă numărul  este divizibil cu &lt;code&gt;p&lt;/code&gt;, și să se afle exponentul lui &lt;code&gt;p&lt;/code&gt; în descompunerea în factori primi a acestui număr.  = Date de intrare = Programul citește de la tastatură numerele &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt; și &lt;code&gt;p&lt;/code&gt;, separate...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=1011_-_p3factoriale&amp;diff=10107&amp;oldid=prev"/>
		<updated>2024-06-04T08:34:09Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă:  = Cerința = Se dau &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; numere naturale, astfel încât &amp;lt;code&amp;gt;a ≥ b + c&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; număr prim. Să se afle dacă numărul  este divizibil cu &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;, și să se afle exponentul lui &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; în descompunerea în factori primi a acestui număr.  = Date de intrare = Programul citește de la tastatură numerele &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;, separate...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
= Cerința =&lt;br /&gt;
Se dau &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; numere naturale, astfel încât &amp;lt;code&amp;gt;a ≥ b + c&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; număr prim. Să se afle dacă numărul  este divizibil cu &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;, și să se afle exponentul lui &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; în descompunerea în factori primi a acestui număr.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Programul citește de la tastatură numerele &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;, separate prin spații.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Programul va afișa pe ecran numărul &amp;lt;code&amp;gt;e&amp;lt;/code&amp;gt;, reprezentând exponentul lui &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; în descompunerea în factori primi a numărului natural . Dacă numărul nu este divizibil cu &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;, atunci se va afișa &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ a , b , c ≤ 1.000.000.000&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;a ≥ b + c&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;2 ≤ p ≤ 1.000&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Exemplu: =&lt;br /&gt;
Intrare&lt;br /&gt;
 12 4 5 3&lt;br /&gt;
Ieșire&lt;br /&gt;
 3&lt;br /&gt;
&lt;br /&gt;
= Explicație =&lt;br /&gt;
Știm de la matematică faptul că numărul  este natural, deci putem vorbi despre divizibilitatea lui prin &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; ( Numărul  reprezintă combinări de  elemente luate câte  ).&lt;br /&gt;
&lt;br /&gt;
De asemenea se știe că exponentul numărului prim &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; în descompunerea în factori primi a numărului &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;! este , unde prin  am notat partea întreagă a lui .&lt;br /&gt;
&lt;br /&gt;
În exemplul dat avem , deci exponentul este &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Rezolvare ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;&lt;br /&gt;
def count_p_in_factorial(n, p):&lt;br /&gt;
    exponent = 0&lt;br /&gt;
    while n % p == 0:&lt;br /&gt;
        n //= p&lt;br /&gt;
        exponent += 1&lt;br /&gt;
    return exponent&lt;br /&gt;
&lt;br /&gt;
def is_divisible_by_p(a, b, c, p):&lt;br /&gt;
    exponent_a = count_p_in_factorial(a, p)&lt;br /&gt;
    exponent_b = count_p_in_factorial(b, p)&lt;br /&gt;
    exponent_c = count_p_in_factorial(c, p)&lt;br /&gt;
&lt;br /&gt;
    if exponent_a - exponent_b - exponent_c &amp;lt; 0:&lt;br /&gt;
        return 0&lt;br /&gt;
&lt;br /&gt;
    exponent = exponent_a - exponent_b - exponent_c&lt;br /&gt;
    return exponent&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    a, b, c, p = map(int, input().split())&lt;br /&gt;
&lt;br /&gt;
    if a &amp;gt;= b + c:&lt;br /&gt;
        exponent = is_divisible_by_p(a, b, c, p)&lt;br /&gt;
        print(exponent)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;0&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    main()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Danciu</name></author>
	</entry>
</feed>