<?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=3369_-_Balanced_Ternary</id>
	<title>3369 - Balanced Ternary - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=3369_-_Balanced_Ternary"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=3369_-_Balanced_Ternary&amp;action=history"/>
	<updated>2026-05-01T05:38:52Z</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=3369_-_Balanced_Ternary&amp;diff=3080&amp;oldid=prev</id>
		<title>Sovago Rares-Andrei: /* Rezolvare */</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=3369_-_Balanced_Ternary&amp;diff=3080&amp;oldid=prev"/>
		<updated>2023-04-08T09:07:46Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Rezolvare&lt;/span&gt;&lt;/span&gt;&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 09:07, 8 April 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-l64&quot;&gt;Line 64:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 64:&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;if __name__ == &amp;quot;__main__&amp;quot;:&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;if __name__ == &amp;quot;__main__&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&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: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     main(&lt;/div&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;     main(&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 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;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 colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l73&quot;&gt;Line 73:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 73:&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;&amp;lt;/syntaxhighlight&amp;gt;&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;&amp;lt;/syntaxhighlight&amp;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;&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;==Explicatie==&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;&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;Funcția validare_numar_natural(n)&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;&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;Această funcție verifică dacă numărul n dat ca parametru este un număr natural valid. Are un singur parametru:&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;&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;n - numărul natural de verificat&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;Funcția returnează True dacă n este un număr natural valid și False în caz contrar.&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;&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;Funcția reprezentare_baza_3_echilibrata(n)&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;&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;Această funcție primește un număr natural n și returnează reprezentarea în baza 3 echilibrată a acestuia. Funcția împarte repetat numărul la 3 și adaugă restul împărțirii la reprezentare, în ordine inversă. Dacă restul este 2, acesta este înlocuit cu litera &quot;T&quot;, iar numărul este incrementat cu 1. Acest proces continuă până când numărul devine 0.&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;&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;Funcția main()&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;&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;Această funcție este funcția principală a programului și este rulată atunci când scriptul Python este executat. Funcția citește de la tastatură un număr natural, verifică dacă acesta este valid cu ajutorul funcției validare_numar_natural(n), calculează reprezentarea în baza 3 echilibrată a numărului dat cu ajutorul funcției reprezentare_baza_3_echilibrata(n) și afișează rezultatul la consolă. Dacă numărul dat nu corespunde restricțiilor impuse, se afișează un mesaj de eroare.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sovago Rares-Andrei</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=3369_-_Balanced_Ternary&amp;diff=1466&amp;oldid=prev</id>
		<title>Sovago Rares-Andrei: Pagină nouă: == Cerinţa == Reprezentarea unui număr natural în baza &#039;&#039;&#039;3&#039;&#039;&#039; echilibrată conține cifrele &#039;&#039;&#039;1 0 -1&#039;&#039;&#039; și se obține scriind numărul ca sumă de puteri ale lui &#039;&#039;&#039;3&#039;&#039;&#039;, înmulțite cu &#039;&#039;&#039;-1, 1 sau 0&#039;&#039;&#039;. Pentru a evita confuziile, cifra egală cu &#039;&#039;&#039;-1&#039;&#039;&#039; se notează cu &#039;&#039;&#039;T&#039;&#039;&#039;, astfel că cifrele din baza &#039;&#039;&#039;3&#039;&#039;&#039; echilibrată sunt &#039;&#039;&#039;1 0 T&#039;&#039;&#039;. Astfel, numărul 11 este egal cu &#039;&#039;&#039;3^2∗(1)+3^1∗(1)+3^0∗(−1)&#039;&#039;&#039;și se reprezintă în baza &#039;&#039;&#039;3&#039;&#039;&#039; echilibrată &#039;&#039;&#039;11T...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=3369_-_Balanced_Ternary&amp;diff=1466&amp;oldid=prev"/>
		<updated>2023-03-23T16:17:02Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: == Cerinţa == Reprezentarea unui număr natural în baza &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039; echilibrată conține cifrele &amp;#039;&amp;#039;&amp;#039;1 0 -1&amp;#039;&amp;#039;&amp;#039; și se obține scriind numărul ca sumă de puteri ale lui &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039;, înmulțite cu &amp;#039;&amp;#039;&amp;#039;-1, 1 sau 0&amp;#039;&amp;#039;&amp;#039;. Pentru a evita confuziile, cifra egală cu &amp;#039;&amp;#039;&amp;#039;-1&amp;#039;&amp;#039;&amp;#039; se notează cu &amp;#039;&amp;#039;&amp;#039;T&amp;#039;&amp;#039;&amp;#039;, astfel că cifrele din baza &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039; echilibrată sunt &amp;#039;&amp;#039;&amp;#039;1 0 T&amp;#039;&amp;#039;&amp;#039;. Astfel, numărul 11 este egal cu &amp;#039;&amp;#039;&amp;#039;3^2∗(1)+3^1∗(1)+3^0∗(−1)&amp;#039;&amp;#039;&amp;#039;și se reprezintă în baza &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039; echilibrată &amp;#039;&amp;#039;&amp;#039;11T...&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;
Reprezentarea unui număr natural în baza &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039; echilibrată conține cifrele &amp;#039;&amp;#039;&amp;#039;1 0 -1&amp;#039;&amp;#039;&amp;#039; și se obține scriind numărul ca sumă de puteri ale lui &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039;, înmulțite cu &amp;#039;&amp;#039;&amp;#039;-1, 1 sau 0&amp;#039;&amp;#039;&amp;#039;. Pentru a evita confuziile, cifra egală cu &amp;#039;&amp;#039;&amp;#039;-1&amp;#039;&amp;#039;&amp;#039; se notează cu &amp;#039;&amp;#039;&amp;#039;T&amp;#039;&amp;#039;&amp;#039;, astfel că cifrele din baza &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039; echilibrată sunt &amp;#039;&amp;#039;&amp;#039;1 0 T&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
Astfel, numărul 11 este egal cu &amp;#039;&amp;#039;&amp;#039;3^2∗(1)+3^1∗(1)+3^0∗(−1)&amp;#039;&amp;#039;&amp;#039;și se reprezintă în baza &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039; echilibrată &amp;#039;&amp;#039;&amp;#039;11T&amp;#039;&amp;#039;&amp;#039;.Se dă un număr natural n.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Să se reprezinte numărul în baza &amp;#039;&amp;#039;&amp;#039;3&amp;#039;&amp;#039;&amp;#039; echilibrată.&lt;br /&gt;
== Date de intrare ==&lt;br /&gt;
Programul citește de la tastatură numărul natural &amp;#039;&amp;#039;&amp;#039;n&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
== Date de ieșire == &lt;br /&gt;
Dacă datele sunt introduse corect, pe ecran se va afișa: &lt;br /&gt;
&amp;quot;Datele sunt introduse corect.&amp;quot;, programul va afișa pe ecran o secvență de caractere, reprezentând numărul n scris în baza 3 echilibrată. În cazul în care datele nu respectă restricțiile, se va afișa pe ecran: &amp;quot;Datele nu corespund restricțiilor impuse.&amp;quot;.&lt;br /&gt;
== Restricţii şi precizări ==&lt;br /&gt;
* 0 ≤ n ≤ 1000000000&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
== Exemple ==&lt;br /&gt;
===Exemplul 1===&lt;br /&gt;
; &amp;#039;&amp;#039;Intrare&amp;#039;&amp;#039;&lt;br /&gt;
: 25&lt;br /&gt;
; &amp;#039;&amp;#039;Ieșire&amp;#039;&amp;#039;&lt;br /&gt;
:Datele sunt introduse corect.&lt;br /&gt;
:10T1&lt;br /&gt;
=== Exemplul 2 ===&lt;br /&gt;
; Intrare:&lt;br /&gt;
: 999999999&lt;br /&gt;
; Ieșire:&lt;br /&gt;
: Datele nu corespund restricțiilor impuse.&lt;br /&gt;
===Exemplul 3===&lt;br /&gt;
; &amp;#039;&amp;#039;Intrare&amp;#039;&amp;#039;&lt;br /&gt;
: 27&lt;br /&gt;
; &amp;#039;&amp;#039;Ieșire&amp;#039;&amp;#039;&lt;br /&gt;
:Datele sunt introduse corect.&lt;br /&gt;
:1000&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&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;
# 3369 - Balanced Ternary&lt;br /&gt;
def validare_numar_natural(n):&lt;br /&gt;
    if n &amp;lt; 0 or n &amp;gt; 1000000000:&lt;br /&gt;
        return False&lt;br /&gt;
    else:&lt;br /&gt;
        return True&lt;br /&gt;
&lt;br /&gt;
def reprezentare_baza_3_echilibrata(n):&lt;br /&gt;
    reprezentare = &amp;quot;&amp;quot;&lt;br /&gt;
    while n != 0:&lt;br /&gt;
        rest = n % 3&lt;br /&gt;
        n //= 3&lt;br /&gt;
        if rest == 2:&lt;br /&gt;
            rest = &amp;quot;T&amp;quot;&lt;br /&gt;
            n += 1&lt;br /&gt;
        reprezentare = str(rest) + reprezentare&lt;br /&gt;
    if reprezentare == &amp;quot;&amp;quot;:&lt;br /&gt;
        reprezentare = &amp;quot;0&amp;quot;&lt;br /&gt;
    return reprezentare&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    n = int(input(&amp;quot;Introduceți un număr natural: &amp;quot;))&lt;br /&gt;
    if validare_numar_natural(n):&lt;br /&gt;
        print(&amp;quot;Datele sunt introduse corect.&amp;quot;)&lt;br /&gt;
        print(&amp;quot;Reprezentarea în baza 3 echilibrată a numărului dat este:&amp;quot;, reprezentare_baza_3_echilibrata(n))&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;Datele nu corespund restricțiilor impuse.&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;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sovago Rares-Andrei</name></author>
	</entry>
</feed>