<?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=4240_-_Nr_Secv_01</id>
	<title>4240 - Nr Secv 01 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=4240_-_Nr_Secv_01"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=4240_-_Nr_Secv_01&amp;action=history"/>
	<updated>2026-05-02T11:54:40Z</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=4240_-_Nr_Secv_01&amp;diff=6069&amp;oldid=prev</id>
		<title>Vardai Erwin: /* Date de ieșire */</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=4240_-_Nr_Secv_01&amp;diff=6069&amp;oldid=prev"/>
		<updated>2023-05-06T18:23:05Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Date de ieșire&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 18:23, 6 May 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-l11&quot;&gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&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;==Date de ieșire==&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;==Date de ieșire==&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; 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;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*&lt;/del&gt;un număr întreg de tip &#039;&#039;&#039;long long&#039;&#039;&#039;, reprezentând numărul de secvențe care conțin exact un caracter &#039;&#039;&#039;1&#039;&#039;&#039;.&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Dacă datele sunt introduse corect, pe ecran se va afișa: &quot;Datele de intrare corespund restricțiilor impuse.&quot; și programul va afișa &lt;/ins&gt;un număr întreg de tip &#039;&#039;&#039;long long&#039;&#039;&#039;, reprezentând numărul de secvențe care conțin exact un caracter &#039;&#039;&#039;1&#039;&#039;&#039;. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;În caz contrar, se va afișa pe ecran: &quot;Datele de intrare nu corespund restricțiilor impuse.&quot;&lt;/ins&gt;&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; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&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; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&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;== Restricții de precizări ==&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;== Restricții de precizări ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Vardai Erwin</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=4240_-_Nr_Secv_01&amp;diff=6068&amp;oldid=prev</id>
		<title>Vardai Erwin: /* Date de intrare */</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=4240_-_Nr_Secv_01&amp;diff=6068&amp;oldid=prev"/>
		<updated>2023-05-06T18:22:42Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Date de intrare&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 18:22, 6 May 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-l7&quot;&gt;Line 7:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&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;==Date de intrare==&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;==Date de intrare==&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;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*&lt;/del&gt;un șir de caractere &#039;&#039;&#039;s&#039;&#039;&#039;, format din caracterele &#039;&#039;&#039;0 &#039;&#039;&#039;&#039;și &#039;&#039;&#039;1&#039;&#039;&#039;, cu o lungime maximă de &#039;&#039;&#039;200.000&#039;&#039;&#039;.&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;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Se citește de la tastatură &lt;/ins&gt;un șir de caractere &#039;&#039;&#039;s&#039;&#039;&#039;, format din caracterele &#039;&#039;&#039;0 &#039;&#039;&#039;&#039;și &#039;&#039;&#039;1&#039;&#039;&#039;, cu o lungime maximă de &#039;&#039;&#039;200.000&#039;&#039;&#039;.&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;==Date de ieșire==&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;==Date de ieșire==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Vardai Erwin</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=4240_-_Nr_Secv_01&amp;diff=6067&amp;oldid=prev</id>
		<title>Vardai Erwin: /* Explicatie */</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=4240_-_Nr_Secv_01&amp;diff=6067&amp;oldid=prev"/>
		<updated>2023-05-06T18:22:26Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Explicatie&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 18:22, 6 May 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-l70&quot;&gt;Line 70:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 70:&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 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; 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;==&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Explicatie&lt;/del&gt;==&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;==&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 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;Funcția NrSecv01 primește un șir de caractere s și folosește o variabilă count pentru a număra secvențele care conțin exact un caracter &amp;#039;1&amp;#039;. Variabila ones numără câte &amp;#039;1&amp;#039; consecutivi există în șirul s, iar atunci când se întâlnește un caracter &amp;#039;0&amp;#039;, se verifică dacă există exact un caracter &amp;#039;1&amp;#039; în secvența anterioară (reprezentată de variabila ones). Dacă da, se incrementează count. În cazul în care există mai mult de un &amp;#039;1&amp;#039; consecutiv, se calculează numărul de perechi de &amp;#039;1&amp;#039; care pot fi formate și se adaugă la count. La final, se mai verifică o dată dacă există exact un &amp;#039;1&amp;#039; în ultima secvență și se adaugă la count dacă este cazul.&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;Funcția NrSecv01 primește un șir de caractere s și folosește o variabilă count pentru a număra secvențele care conțin exact un caracter &amp;#039;1&amp;#039;. Variabila ones numără câte &amp;#039;1&amp;#039; consecutivi există în șirul s, iar atunci când se întâlnește un caracter &amp;#039;0&amp;#039;, se verifică dacă există exact un caracter &amp;#039;1&amp;#039; în secvența anterioară (reprezentată de variabila ones). Dacă da, se incrementează count. În cazul în care există mai mult de un &amp;#039;1&amp;#039; consecutiv, se calculează numărul de perechi de &amp;#039;1&amp;#039; care pot fi formate și se adaugă la count. La final, se mai verifică o dată dacă există exact un &amp;#039;1&amp;#039; în ultima secvență și se adaugă la count dacă este cazul.&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;/table&gt;</summary>
		<author><name>Vardai Erwin</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=4240_-_Nr_Secv_01&amp;diff=5749&amp;oldid=prev</id>
		<title>Cuceu Andrei: Pagină nouă: == Cerință == Scrieți funcția cu următorul antet:    long long NrSecv01(const char s[]) Funcția primește ca parametru un șir format doar din &#039;&#039;&#039;0&#039;&#039;&#039; și &#039;&#039;&#039;1&#039;&#039;&#039; și returnează numărul se secvențe care conțin exact un caracter &#039;&#039;&#039;1&#039;&#039;&#039;.   ==Date de intrare== *un șir de caractere &#039;&#039;&#039;s&#039;&#039;&#039;, format din caracterele &#039;&#039;&#039;0 &#039;&#039;&#039;&#039;și &#039;&#039;&#039;1&#039;&#039;&#039;, cu o lungime maximă de &#039;&#039;&#039;200.000&#039;&#039;&#039;.  ==Date de ieșire==  *un număr întreg de tip &#039;&#039;&#039;long long&#039;&#039;&#039;, reprezentând numărul de secve...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=4240_-_Nr_Secv_01&amp;diff=5749&amp;oldid=prev"/>
		<updated>2023-04-30T18:49:48Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: == Cerință == Scrieți funcția cu următorul antet:    long long NrSecv01(const char s[]) Funcția primește ca parametru un șir format doar din &amp;#039;&amp;#039;&amp;#039;0&amp;#039;&amp;#039;&amp;#039; și &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039; și returnează numărul se secvențe care conțin exact un caracter &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039;.   ==Date de intrare== *un șir de caractere &amp;#039;&amp;#039;&amp;#039;s&amp;#039;&amp;#039;&amp;#039;, format din caracterele &amp;#039;&amp;#039;&amp;#039;0 &amp;#039;&amp;#039;&amp;#039;&amp;#039;și &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039;, cu o lungime maximă de &amp;#039;&amp;#039;&amp;#039;200.000&amp;#039;&amp;#039;&amp;#039;.  ==Date de ieșire==  *un număr întreg de tip &amp;#039;&amp;#039;&amp;#039;long long&amp;#039;&amp;#039;&amp;#039;, reprezentând numărul de secve...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Cerință ==&lt;br /&gt;
Scrieți funcția cu următorul antet:&lt;br /&gt;
&lt;br /&gt;
  long long NrSecv01(const char s[])&lt;br /&gt;
Funcția primește ca parametru un șir format doar din &amp;#039;&amp;#039;&amp;#039;0&amp;#039;&amp;#039;&amp;#039; și &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039; și returnează numărul se secvențe care conțin exact un caracter &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Date de intrare==&lt;br /&gt;
*un șir de caractere &amp;#039;&amp;#039;&amp;#039;s&amp;#039;&amp;#039;&amp;#039;, format din caracterele &amp;#039;&amp;#039;&amp;#039;0 &amp;#039;&amp;#039;&amp;#039;&amp;#039;și &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039;, cu o lungime maximă de &amp;#039;&amp;#039;&amp;#039;200.000&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
==Date de ieșire==&lt;br /&gt;
&lt;br /&gt;
*un număr întreg de tip &amp;#039;&amp;#039;&amp;#039;long long&amp;#039;&amp;#039;&amp;#039;, reprezentând numărul de secvențe care conțin exact un caracter &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Restricții de precizări ==&lt;br /&gt;
&lt;br /&gt;
*Lungimea șirului &amp;#039;&amp;#039;&amp;#039;s&amp;#039;&amp;#039;&amp;#039; va fi de cel mult &amp;#039;&amp;#039;&amp;#039;200.000&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
*Puteți utiliza funcțiile pentru șirurile de caractere din biblioteca &amp;#039;&amp;#039;&amp;#039;cstring&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Exemplu==&lt;br /&gt;
=== Exemplul 1===&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NrSecv01(&amp;quot;0101&amp;quot;) = 6&amp;#039;&amp;#039;&amp;#039;, secvențele care conțin exact un&amp;#039;&amp;#039;&amp;#039; 1&amp;#039;&amp;#039;&amp;#039; fiind: &amp;#039;&amp;#039;&amp;#039;01, 010, 1, 10, 01, 1&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
==Important==&lt;br /&gt;
&lt;br /&gt;
Soluţia propusă va conţine doar definiţia subprogramului cerut. Prezenţa în soluţie a altor instrucţiuni poate duce erori de compilare sau de execuţie care vor avea ca efect depunctarea soluţiei.&lt;br /&gt;
&lt;br /&gt;
==Rezolvare==&lt;br /&gt;
=== Rezolvare var. 1 ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;quot;1&amp;quot; start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
def NrSecv01(s: str) -&amp;gt; int:&lt;br /&gt;
    n = len(s)&lt;br /&gt;
    count = 0&lt;br /&gt;
    ones = 0&lt;br /&gt;
    for i in range(n):&lt;br /&gt;
        if s[i] == &amp;#039;1&amp;#039;:&lt;br /&gt;
            ones += 1&lt;br /&gt;
        elif ones == 1:&lt;br /&gt;
            count += 1&lt;br /&gt;
        elif ones &amp;gt; 1:&lt;br /&gt;
            count += ones*(ones-1)//2&lt;br /&gt;
            ones = 0&lt;br /&gt;
    if ones == 1:&lt;br /&gt;
        count += 1&lt;br /&gt;
    elif ones &amp;gt; 1:&lt;br /&gt;
        count += ones*(ones-1)//2&lt;br /&gt;
    return count&lt;br /&gt;
&lt;br /&gt;
def validate_input(s: str) -&amp;gt; bool:&lt;br /&gt;
    if len(s) &amp;gt; 200000:&lt;br /&gt;
        return False&lt;br /&gt;
    for c in s:&lt;br /&gt;
        if c not in {&amp;#039;0&amp;#039;, &amp;#039;1&amp;#039;}:&lt;br /&gt;
            return False&lt;br /&gt;
    return True&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;#039;__main__&amp;#039;:&lt;br /&gt;
    s = input().strip()&lt;br /&gt;
    if not validate_input(s):&lt;br /&gt;
        print(&amp;quot;Input invalid&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(NrSecv01(s))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explicatie==&lt;br /&gt;
Funcția NrSecv01 primește un șir de caractere s și folosește o variabilă count pentru a număra secvențele care conțin exact un caracter &amp;#039;1&amp;#039;. Variabila ones numără câte &amp;#039;1&amp;#039; consecutivi există în șirul s, iar atunci când se întâlnește un caracter &amp;#039;0&amp;#039;, se verifică dacă există exact un caracter &amp;#039;1&amp;#039; în secvența anterioară (reprezentată de variabila ones). Dacă da, se incrementează count. În cazul în care există mai mult de un &amp;#039;1&amp;#039; consecutiv, se calculează numărul de perechi de &amp;#039;1&amp;#039; care pot fi formate și se adaugă la count. La final, se mai verifică o dată dacă există exact un &amp;#039;1&amp;#039; în ultima secvență și se adaugă la count dacă este cazul.&lt;br /&gt;
&lt;br /&gt;
Funcția validate_input verifică dacă șirul de intrare respectă restricțiile impuse: lungimea maximă este de 200.000, iar șirul trebuie să conțină doar caracterele &amp;#039;0&amp;#039; și &amp;#039;1&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
În programul principal, se citește șirul de la tastatură și se validează. Dacă șirul nu este valid, se afișează un mesaj corespunzător, altfel se apelează funcția NrSecv01 și se afișează rezultatul.&lt;/div&gt;</summary>
		<author><name>Cuceu Andrei</name></author>
	</entry>
</feed>