<?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=0955_-_Miny</id>
	<title>0955 - Miny - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=0955_-_Miny"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0955_-_Miny&amp;action=history"/>
	<updated>2026-05-02T21:10:37Z</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=0955_-_Miny&amp;diff=9028&amp;oldid=prev</id>
		<title>Miawinator: Pagină nouă: Fie &lt;code&gt;N&lt;/code&gt; un număr natural nenul şi &lt;code&gt;N&lt;/code&gt; numere naturale nenule: &lt;code&gt;x1&lt;/code&gt;, &lt;code&gt;x2&lt;/code&gt;,…, &lt;code&gt;xN&lt;/code&gt;.  Fie &lt;code&gt;P&lt;/code&gt; produsul acestor N numere, &lt;code&gt;P=x1•x2•...•xN&lt;/code&gt;.  = Cerinţe = Scrieţi un program care să citească numerele &lt;code&gt;N&lt;/code&gt;, &lt;code&gt;x1&lt;/code&gt;, &lt;code&gt;x2&lt;/code&gt;,…, &lt;code&gt;xN&lt;/code&gt; şi apoi să determine:  a) cifra zecilor produsului &lt;code&gt;P&lt;/code&gt;;  b) cel mai mic număr natural &lt;code&gt;Y&lt;/code&gt;, pentru ca...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0955_-_Miny&amp;diff=9028&amp;oldid=prev"/>
		<updated>2024-01-04T22:00:14Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: Fie &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; un număr natural nenul şi &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; numere naturale nenule: &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x2&amp;lt;/code&amp;gt;,…, &amp;lt;code&amp;gt;xN&amp;lt;/code&amp;gt;.  Fie &amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; produsul acestor N numere, &amp;lt;code&amp;gt;P=x1•x2•...•xN&amp;lt;/code&amp;gt;.  = Cerinţe = Scrieţi un program care să citească numerele &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x2&amp;lt;/code&amp;gt;,…, &amp;lt;code&amp;gt;xN&amp;lt;/code&amp;gt; şi apoi să determine:  a) cifra zecilor produsului &amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;;  b) cel mai mic număr natural &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;, pentru ca...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Fie &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; un număr natural nenul şi &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; numere naturale nenule: &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x2&amp;lt;/code&amp;gt;,…, &amp;lt;code&amp;gt;xN&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Fie &amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt; produsul acestor N numere, &amp;lt;code&amp;gt;P=x1•x2•...•xN&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Cerinţe =&lt;br /&gt;
Scrieţi un program care să citească numerele &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x2&amp;lt;/code&amp;gt;,…, &amp;lt;code&amp;gt;xN&amp;lt;/code&amp;gt; şi apoi să determine:&lt;br /&gt;
&lt;br /&gt;
a) cifra zecilor produsului &amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
b) cel mai mic număr natural &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;, pentru care există numărul natural &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; astfel încât &amp;lt;code&amp;gt;YK=P&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Fișierul de intrare &amp;lt;code&amp;gt;input.txt&amp;lt;/code&amp;gt; conţine două linii. Pe prima linie este scris numărul natural &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;. Pe următoarea linie sunt scrise cele &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; numere naturale &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x2&amp;lt;/code&amp;gt;,…, &amp;lt;code&amp;gt;xN&amp;lt;/code&amp;gt;, separate prin câte un spaţiu.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Fișierul de ieșire &amp;lt;code&amp;gt;output.txt&amp;lt;/code&amp;gt; va conține:&lt;br /&gt;
&lt;br /&gt;
* pe prima linie o cifră reprezentând cifra zecilor produsului &amp;lt;code&amp;gt;P&amp;lt;/code&amp;gt;;&lt;br /&gt;
* pe a doua linie numărul natural M de factori primi din descompunerea în factori primi a numărului &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;;&lt;br /&gt;
* pe fiecare dintre următoarele &amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt; linii (câte o linie pentru fiecare factor prim din descompunere) câte două valori &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt;, separate printr-un singur spaţiu, &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; reprezentând factorul prim iar &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; exponentul acestui factor din descompunerea în factori primi a lui &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;; scrierea în fişier a acestor factori primi se va face în ordinea crescătoare a valorii lor.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;2 ≤  N ≤ 50000&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exemplul 1 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
6&lt;br /&gt;
&lt;br /&gt;
12 5 60 25 4 36&lt;br /&gt;
&lt;br /&gt;
output.txt:&lt;br /&gt;
&lt;br /&gt;
0&lt;br /&gt;
&lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
2 2&lt;br /&gt;
&lt;br /&gt;
3 1&lt;br /&gt;
&lt;br /&gt;
5 1&lt;br /&gt;
&lt;br /&gt;
Explicație:&lt;br /&gt;
&lt;br /&gt;
Produsul celor &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt; numere este: &amp;lt;code&amp;gt;P=12∙5∙60∙25∙4∙36=12960000&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Cifra zecilor lui P este &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Se observă că există &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; valori posibile pentru &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;12960000&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;3600&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;60&amp;lt;/code&amp;gt; deoarece: &amp;lt;code&amp;gt;129600001=12960000&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;36002=12960000&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;604=12960000&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Cea mai mică valoare dintre aceste valori este &amp;lt;code&amp;gt;60&amp;lt;/code&amp;gt;, astfel &amp;lt;code&amp;gt;Y=60=(2**2)*3*5&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Exemplul 2 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
2 5 7&lt;br /&gt;
&lt;br /&gt;
output.txt:&lt;br /&gt;
&lt;br /&gt;
7&lt;br /&gt;
&lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
2 1&lt;br /&gt;
&lt;br /&gt;
5 1&lt;br /&gt;
&lt;br /&gt;
7 1&lt;br /&gt;
&lt;br /&gt;
Explicație:&lt;br /&gt;
&lt;br /&gt;
Produsul celor &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; numere este: &amp;lt;code&amp;gt;P=2∙5∙7=70&amp;lt;/code&amp;gt;. Cifra zecilor lui P este &amp;lt;code&amp;gt;7&amp;lt;/code&amp;gt;. Există o singură valoare posibilă pentru &amp;lt;code&amp;gt;Y&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;70&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Exemplul 3 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
999999999999&lt;br /&gt;
&lt;br /&gt;
2 5 7&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
Input-ul nu convine conditiilor&lt;br /&gt;
&lt;br /&gt;
== Rezolvare ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
def verificare(n):&lt;br /&gt;
    if not(2&amp;lt;=n&amp;lt;=5000):&lt;br /&gt;
        print(&amp;quot;Input-ul nu convine conditiilor&amp;quot;)&lt;br /&gt;
        exit()&lt;br /&gt;
&lt;br /&gt;
def cmmdc(a, b):&lt;br /&gt;
    while a and b:&lt;br /&gt;
        if a &amp;gt; b:&lt;br /&gt;
            a = a % b&lt;br /&gt;
        else:&lt;br /&gt;
            b = b % a&lt;br /&gt;
    return a + b&lt;br /&gt;
&lt;br /&gt;
n = 10000&lt;br /&gt;
v = [0] * (n + 1)&lt;br /&gt;
fr = [0] * (n + 1)&lt;br /&gt;
w = [0] * (n + 1)&lt;br /&gt;
&lt;br /&gt;
# determinare numere prime &amp;lt;=10000 - Ciurul lui Eratostene&lt;br /&gt;
v[2] = 1&lt;br /&gt;
for i in range(3, n + 1, 2):&lt;br /&gt;
    v[i] = 1&lt;br /&gt;
&lt;br /&gt;
for i in range(3, n + 1, 2):&lt;br /&gt;
    if v[i] != 0:&lt;br /&gt;
        for j in range(2 * i, n + 1, i):&lt;br /&gt;
            v[j] = 0&lt;br /&gt;
&lt;br /&gt;
with open(&amp;quot;input.txt&amp;quot;, &amp;quot;r&amp;quot;) as f, open(&amp;quot;output.txt&amp;quot;, &amp;quot;w&amp;quot;) as g:&lt;br /&gt;
    N = int(f.readline())&lt;br /&gt;
    verificare(N)&lt;br /&gt;
    l=list(map(int, f.readline().split()))&lt;br /&gt;
    p = 1&lt;br /&gt;
    for i in range(N):&lt;br /&gt;
        x = l[i]&lt;br /&gt;
        fr[x] += 1&lt;br /&gt;
        p = (p * x) % 100&lt;br /&gt;
&lt;br /&gt;
    for i in range(2, n + 1):&lt;br /&gt;
        if fr[i]:&lt;br /&gt;
            if v[i]:&lt;br /&gt;
                w[i] += fr[i]&lt;br /&gt;
            else:&lt;br /&gt;
                x = i&lt;br /&gt;
                for j in range(2, n + 1):&lt;br /&gt;
                    while v[j] and (x % j == 0) and x &amp;gt; 1:&lt;br /&gt;
                        w[j] += fr[i]&lt;br /&gt;
                        x //= j&lt;br /&gt;
&lt;br /&gt;
    M = 0&lt;br /&gt;
    d = 0&lt;br /&gt;
    for i in range(2, n + 1):&lt;br /&gt;
        if w[i]:&lt;br /&gt;
            M += 1&lt;br /&gt;
            d = cmmdc(d, w[i])&lt;br /&gt;
&lt;br /&gt;
    g.write(f&amp;quot;{p // 10}\n{M}\n&amp;quot;)&lt;br /&gt;
    for i in range(2, n + 1):&lt;br /&gt;
        if w[i]:&lt;br /&gt;
            g.write(f&amp;quot;{i} {w[i] // d}\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Miawinator</name></author>
	</entry>
</feed>