<?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=3152_-_combinari2</id>
	<title>3152 - combinari2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=3152_-_combinari2"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=3152_-_combinari2&amp;action=history"/>
	<updated>2026-05-01T07:23:18Z</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=3152_-_combinari2&amp;diff=7724&amp;oldid=prev</id>
		<title>Gabii: am adaugat explicatia</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=3152_-_combinari2&amp;diff=7724&amp;oldid=prev"/>
		<updated>2023-12-09T22:18:58Z</updated>

		<summary type="html">&lt;p&gt;am adaugat explicatia&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:18, 9 December 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l25&quot;&gt;Line 25:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  2 3 5  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  2 3 5  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  3 4 5  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  3 4 5  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Explicație ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Numrele &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; nu apar pe poziții alăturate.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Exemplul 2 =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Exemplul 2 =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gabii</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=3152_-_combinari2&amp;diff=7648&amp;oldid=prev</id>
		<title>Gabii: Pagină nouă:  = Cerința = Se citesc două numere naturale &lt;code&gt;n&lt;/code&gt; și &lt;code&gt;m&lt;/code&gt;. Afișați în ordine lexicografică toate submulțimile cu &lt;code&gt;m&lt;/code&gt; elemente ale mulțimii &lt;code&gt;{1, 2, ..., n}&lt;/code&gt; în care nu există două elemente pare alăturate.  = Date de intrare = Programul citește de la tastatură numerele &lt;code&gt;n&lt;/code&gt; și &lt;code&gt;m&lt;/code&gt;.  = Date de ieșire = Programul va afișa pe ecran submulțimile cerute, câte una pe fiecare rand și având elementele s...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=3152_-_combinari2&amp;diff=7648&amp;oldid=prev"/>
		<updated>2023-12-04T19:31:07Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă:  = Cerința = Se citesc două numere naturale &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt;. Afișați în ordine lexicografică toate submulțimile cu &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; elemente ale mulțimii &amp;lt;code&amp;gt;{1, 2, ..., n}&amp;lt;/code&amp;gt; în care nu există două elemente pare alăturate.  = Date de intrare = Programul citește de la tastatură numerele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt;.  = Date de ieșire = Programul va afișa pe ecran submulțimile cerute, câte una pe fiecare rand și având elementele s...&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 citesc două numere naturale &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt;. Afișați în ordine lexicografică toate submulțimile cu &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt; elemente ale mulțimii &amp;lt;code&amp;gt;{1, 2, ..., n}&amp;lt;/code&amp;gt; în care nu există două elemente pare alăturate.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Programul citește de la tastatură numerele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;m&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Programul va afișa pe ecran submulțimile cerute, câte una pe fiecare rand și având elementele separate prin câte un spaţiu. În cazul în care restricțiile nu sunt îndeplinite, se va afișa mesajul &amp;quot;Nu corespunde restricțiilor&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ m &amp;lt; n ≤ 20&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Exemplul 1 =&lt;br /&gt;
Intrare&lt;br /&gt;
 5 3&lt;br /&gt;
Ieșire&lt;br /&gt;
 1 2 3 &lt;br /&gt;
 1 2 5 &lt;br /&gt;
 1 3 4 &lt;br /&gt;
 1 3 5 &lt;br /&gt;
 1 4 5 &lt;br /&gt;
 2 3 4 &lt;br /&gt;
 2 3 5 &lt;br /&gt;
 3 4 5 &lt;br /&gt;
&lt;br /&gt;
= Exemplul 2 =&lt;br /&gt;
Intrare&lt;br /&gt;
 22 17&lt;br /&gt;
consola&lt;br /&gt;
 Nu corespunde restricțiilor&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 este_input_valid(n, m):&lt;br /&gt;
    return 1 &amp;lt;= m &amp;lt; n &amp;lt;= 20&lt;br /&gt;
&lt;br /&gt;
def este_submultime_valida(submultime):&lt;br /&gt;
    for i in range(len(submultime) - 1):&lt;br /&gt;
        if submultime[i] % 2 == 0 and submultime[i + 1] % 2 == 0:&lt;br /&gt;
            return False&lt;br /&gt;
    return True&lt;br /&gt;
&lt;br /&gt;
def genereaza_submultimi(n, m, submultime_curenta, index):&lt;br /&gt;
    if len(submultime_curenta) == m:&lt;br /&gt;
        if este_submultime_valida(submultime_curenta):&lt;br /&gt;
            print(*submultime_curenta)&lt;br /&gt;
        return&lt;br /&gt;
&lt;br /&gt;
    if index &amp;gt; n:&lt;br /&gt;
        return&lt;br /&gt;
&lt;br /&gt;
    # Include elementul la index în submulțime&lt;br /&gt;
    genereaza_submultimi(n, m, submultime_curenta + [index], index + 1)&lt;br /&gt;
&lt;br /&gt;
    # Sări peste elementul la index&lt;br /&gt;
    genereaza_submultimi(n, m, submultime_curenta, index + 1)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    n, m = map(int, input(&amp;quot;Introduceți valorile pentru n și m (separate prin spațiu): &amp;quot;).split())&lt;br /&gt;
&lt;br /&gt;
    if not este_input_valid(n, m):&lt;br /&gt;
        print(&amp;quot;Nu corespunde restricțiilor&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(f&amp;quot;Submulțimile cu {m} elemente ale mulțimii {{1, 2, ..., {n}}} în care nu există două elemente pare alăturate sunt:&amp;quot;)&lt;br /&gt;
        genereaza_submultimi(n, m, [], 1)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gabii</name></author>
	</entry>
</feed>