<?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=1330_-_ParitiiMultime</id>
	<title>1330 - ParitiiMultime - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=1330_-_ParitiiMultime"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=1330_-_ParitiiMultime&amp;action=history"/>
	<updated>2026-05-01T12:08:10Z</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=1330_-_ParitiiMultime&amp;diff=9825&amp;oldid=prev</id>
		<title>Oros Ioana Diana: Pagină nouă: = Cerința = Fie &lt;code&gt;n&lt;/code&gt; un număr natural nenul și mulțimea &lt;code&gt;A={1,2,3,...,n}&lt;/code&gt;. Să se determine toate partițiile disjuncte ale mulțimii &lt;code&gt;A&lt;/code&gt;.  O partiție a mulțimii &lt;code&gt;A&lt;/code&gt; este formată din &lt;code&gt;m&lt;/code&gt; (&lt;code&gt;1 ≤ m ≤ n&lt;/code&gt;) submulțimi disjuncte ale lui &lt;code&gt;A&lt;/code&gt;: &lt;code&gt;A1&lt;/code&gt;, &lt;code&gt;A2&lt;/code&gt;, …, &lt;code&gt;Am&lt;/code&gt; cu proprietatea că &lt;code&gt;A=A1U A2&lt;/code&gt; &lt;code&gt;U...U Am&lt;/code&gt;.  = Date de intrare = Fișierul de int...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=1330_-_ParitiiMultime&amp;diff=9825&amp;oldid=prev"/>
		<updated>2024-05-18T19:44:29Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: = Cerința = Fie &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; un număr natural nenul și mulțimea &amp;lt;code&amp;gt;A={1,2,3,...,n}&amp;lt;/code&amp;gt;. Să se determine toate partițiile disjuncte ale mulțimii &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;.  O partiție a mulțimii &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; este formată din &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;1 ≤ m ≤ n&amp;lt;/code&amp;gt;) submulțimi disjuncte ale lui &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;A1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;A2&amp;lt;/code&amp;gt;, …, &amp;lt;code&amp;gt;Am&amp;lt;/code&amp;gt; cu proprietatea că &amp;lt;code&amp;gt;A=A1U A2&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;U...U Am&amp;lt;/code&amp;gt;.  = Date de intrare = Fișierul de int...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Cerința =&lt;br /&gt;
Fie &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; un număr natural nenul și mulțimea &amp;lt;code&amp;gt;A={1,2,3,...,n}&amp;lt;/code&amp;gt;. Să se determine toate partițiile disjuncte ale mulțimii &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
O partiție a mulțimii &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt; este formată din &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;1 ≤ m ≤ n&amp;lt;/code&amp;gt;) submulțimi disjuncte ale lui &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;A1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;A2&amp;lt;/code&amp;gt;, …, &amp;lt;code&amp;gt;Am&amp;lt;/code&amp;gt; cu proprietatea că &amp;lt;code&amp;gt;A=A1U A2&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;U...U Am&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;partitiimultimeIN.txt&amp;lt;/code&amp;gt; conține pe prima linie numărul &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Fișierul de ieșire &amp;lt;code&amp;gt;partitiimultimeOUT.txt&amp;lt;/code&amp;gt; va conține câte o linie pentru fiecare partiție determinată. Submulțimile vor fi separate în fiecare linie cu ajutorul caracterului &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt;, iar elementele fiecărei submulțimi se vor scrie fără spațiere, ca în exemplul de mai jos.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ n ≤ 9&amp;lt;/code&amp;gt;&lt;br /&gt;
* Partițiile determinate se vor afișa în ordine lexicografică&lt;br /&gt;
&lt;br /&gt;
= Exemplul 1: =&lt;br /&gt;
&amp;lt;code&amp;gt;partitiimultimeIN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 3&lt;br /&gt;
&amp;lt;code&amp;gt;partitiimultimeOUT.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 123*&lt;br /&gt;
 12*3*&lt;br /&gt;
 13*2*&lt;br /&gt;
 1*23*&lt;br /&gt;
 1*2*3*&lt;br /&gt;
&lt;br /&gt;
=== Explicație ===&lt;br /&gt;
Sunt determinate &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; partiții distincte ale mulțimii &amp;lt;code&amp;gt;A&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# &amp;lt;code&amp;gt;{1,2,3}&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;{1,2} U {3}&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;{1,3} U {2}&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;{1} U {2,3}&amp;lt;/code&amp;gt;&lt;br /&gt;
# &amp;lt;code&amp;gt;{1} U {2} U {3}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exemplul 2: ==&lt;br /&gt;
&amp;lt;code&amp;gt;partitiimultimeIN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 10&lt;br /&gt;
&amp;lt;code&amp;gt;partitiimultimeOUT.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 Datele nu corespund restrictiilor impuse&lt;br /&gt;
&lt;br /&gt;
== Rezolvare ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
def maxim(k, x):&lt;br /&gt;
    z = 0&lt;br /&gt;
    for i in range(1, k):&lt;br /&gt;
        z = max(x[i], z)&lt;br /&gt;
    return z&lt;br /&gt;
&lt;br /&gt;
def scrie(x, n, g):&lt;br /&gt;
    z = maxim(n + 1, x)&lt;br /&gt;
    for i in range(1, z + 1):&lt;br /&gt;
        for j in range(1, n + 1):&lt;br /&gt;
            if x[j] == i:&lt;br /&gt;
                g.write(str(j))&lt;br /&gt;
        g.write(&amp;quot;*&amp;quot;)&lt;br /&gt;
    g.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
def back(k, n, x, g):&lt;br /&gt;
    if k == n + 1:&lt;br /&gt;
        scrie(x, n, g)&lt;br /&gt;
    else:&lt;br /&gt;
        for i in range(1, maxim(k, x) + 2):&lt;br /&gt;
            x[k] = i&lt;br /&gt;
            back(k + 1, n, x, g)&lt;br /&gt;
&lt;br /&gt;
def verifica_restrictii(n, g):&lt;br /&gt;
    if not (1 &amp;lt;= n &amp;lt;= 9):&lt;br /&gt;
        g.write(&amp;quot;Datele nu corespund restrictiilor impuse\n&amp;quot;)&lt;br /&gt;
        return False&lt;br /&gt;
    return True&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    with open(&amp;quot;partitiimultimeIN.txt&amp;quot;, &amp;quot;r&amp;quot;) as f:&lt;br /&gt;
        n = int(f.readline().strip())&lt;br /&gt;
&lt;br /&gt;
    with open(&amp;quot;partitiimultimeOUT.txt&amp;quot;, &amp;quot;w&amp;quot;) as g:&lt;br /&gt;
        if verifica_restrictii(n, g):&lt;br /&gt;
            x = [0] * (n + 1)&lt;br /&gt;
            x[1] = 1&lt;br /&gt;
            back(2, n, x, g)&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>Oros Ioana Diana</name></author>
	</entry>
</feed>