<?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=1537_-_7_Segmente</id>
	<title>1537 - 7 Segmente - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=1537_-_7_Segmente"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=1537_-_7_Segmente&amp;action=history"/>
	<updated>2026-06-17T08:33:57Z</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=1537_-_7_Segmente&amp;diff=9020&amp;oldid=prev</id>
		<title>Corjuc Eunice: Pagină nouă: Un indicator cu &lt;code&gt;7&lt;/code&gt; segmente este un dispozitiv de afişaj electronic destinat afişării unei cifre zecimale. Aceste dispozitive sunt utilizate pe scară largă în ceasuri digitale, contoare electronice şi alte aparate, pentru afişarea informaţiilor numerice. Cele &lt;code&gt;7&lt;/code&gt; segmente au fost notate cu literele &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;, &lt;code&gt;f&lt;/code&gt;, &lt;code&gt;g&lt;/code&gt;, după modelul din figura de mai jos....</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=1537_-_7_Segmente&amp;diff=9020&amp;oldid=prev"/>
		<updated>2024-01-04T20:47:01Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: Un indicator cu &amp;lt;code&amp;gt;7&amp;lt;/code&amp;gt; segmente este un dispozitiv de afişaj electronic destinat afişării unei cifre zecimale. Aceste dispozitive sunt utilizate pe scară largă în ceasuri digitale, contoare electronice şi alte aparate, pentru afişarea informaţiilor numerice. Cele &amp;lt;code&amp;gt;7&amp;lt;/code&amp;gt; segmente au fost notate cu literele &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;d&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;e&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;g&amp;lt;/code&amp;gt;, după modelul din figura de mai jos....&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Un indicator cu &amp;lt;code&amp;gt;7&amp;lt;/code&amp;gt; segmente este un dispozitiv de afişaj electronic destinat afişării unei cifre zecimale. Aceste dispozitive sunt utilizate pe scară largă în ceasuri digitale, contoare electronice şi alte aparate, pentru afişarea informaţiilor numerice. Cele &amp;lt;code&amp;gt;7&amp;lt;/code&amp;gt; segmente au fost notate cu literele &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;c&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;d&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;e&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;f&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;g&amp;lt;/code&amp;gt;, după modelul din figura de mai jos.&lt;br /&gt;
&lt;br /&gt;
Proiectarea diverselor sisteme de afişaj trebuie să ţină cont şi de puterea necesară pentru afişarea unei cifre. Pentru aprinderea unui segment este necesară o putere de &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; mW. Astfel, în funcţie de cifra afişată, dispozitivul necesită o putere egală cu numărul de segmente aprinse la afişarea cifrei respective. Puterea necesară pentru afişarea unui număr natural este egală cu suma puterilor necesare afişării fiecăreia dintre cifrele sale.&lt;br /&gt;
&lt;br /&gt;
= Cerința =&lt;br /&gt;
Să se scrie un program care citeşte două numere naturale nenule &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;, (numărul &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; având toate cifrele nenule)şi calculează:&lt;br /&gt;
&lt;br /&gt;
* numărul natural &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; reprezentând puterea necesară pentru afişarea numărului &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;;&lt;br /&gt;
* cel mai mare număr natural &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt;, format numai din cifre nenule, mai mic sau egal decât &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;, care necesită pentru afişare o putere de cel mult &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; mW.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Prima linie a fişierului de intrare &amp;lt;code&amp;gt;input.txt conţine&amp;lt;/code&amp;gt; două numere naturale nenule &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt;, (numărul &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; având toate cifrele nenule), despărţite printr-un spaţiu, cu semnificaţia de mai sus.&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 pe o singură linie, cele două numere naturale nenule &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; şi &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; (numărul &amp;lt;code&amp;gt;t&amp;lt;/code&amp;gt; având toate cifrele nenule), separate printr-un spaţiu, cu semnificaţia de mai sus.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ n &amp;lt; 10**19&amp;lt;/code&amp;gt;;&lt;br /&gt;
* &amp;lt;code&amp;gt;2 ≤ p ≤ 150&amp;lt;/code&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
== Exemplul 1 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
7654 12&lt;br /&gt;
&lt;br /&gt;
output.txt:&lt;br /&gt;
&lt;br /&gt;
18 7511&lt;br /&gt;
&lt;br /&gt;
Explicație:&lt;br /&gt;
&lt;br /&gt;
Numărul n este &amp;lt;code&amp;gt;7654&amp;lt;/code&amp;gt;; puterea necesară pentru afişare este &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; + &amp;lt;code&amp;gt;6&amp;lt;/code&amp;gt; + &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; + &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;18&amp;lt;/code&amp;gt; mW, iar cel mai mare număr, mai mic sau egal cu &amp;lt;code&amp;gt;7654&amp;lt;/code&amp;gt;, format numai din cifre nenule, care necesită pentru afişare o putere de cel mult &amp;lt;code&amp;gt;12&amp;lt;/code&amp;gt; mW, este &amp;lt;code&amp;gt;7511&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Exemplul 2 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
7654 9999&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
Constrangeri neindeplinite&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 ver(n,p):&lt;br /&gt;
    if not(1&amp;lt;=n&amp;lt;=10**19):&lt;br /&gt;
        print(&amp;quot;Constrangeri neindeplinite&amp;quot;)&lt;br /&gt;
        exit()&lt;br /&gt;
    if not(2&amp;lt;=p&amp;lt;=150):&lt;br /&gt;
        print(&amp;quot;Constrangeri neindeplinite&amp;quot;)&lt;br /&gt;
        exit()&lt;br /&gt;
&lt;br /&gt;
def main():&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;
        v = [0] * 20&lt;br /&gt;
        t = [0] * 20&lt;br /&gt;
        p = 0&lt;br /&gt;
&lt;br /&gt;
        pw = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]&lt;br /&gt;
&lt;br /&gt;
        n, p = map(int, f.readline().split())&lt;br /&gt;
&lt;br /&gt;
        ver(n,p)&lt;br /&gt;
&lt;br /&gt;
        pc = 0&lt;br /&gt;
        i = 0&lt;br /&gt;
        nc = 0&lt;br /&gt;
        aux = 0&lt;br /&gt;
        dmin = 0&lt;br /&gt;
        dmax = 0&lt;br /&gt;
        cifra = 0&lt;br /&gt;
        egalcif = 1&lt;br /&gt;
&lt;br /&gt;
        v[0] = 0&lt;br /&gt;
        i = 0&lt;br /&gt;
        while n &amp;gt; 0:&lt;br /&gt;
            i += 1&lt;br /&gt;
            v[i] = n % 10&lt;br /&gt;
            case_dict = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}&lt;br /&gt;
            pc += case_dict.get(n % 10, 0)&lt;br /&gt;
            n //= 10&lt;br /&gt;
        v[0] = i&lt;br /&gt;
        g.write(f&amp;quot;{pc} &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        for i in range(1, v[0] // 2 + 1):&lt;br /&gt;
            aux = v[i]&lt;br /&gt;
            v[i] = v[v[0] + 1 - i]&lt;br /&gt;
            v[v[0] + 1 - i] = aux&lt;br /&gt;
&lt;br /&gt;
        nc = p // 2&lt;br /&gt;
        nc = min(nc, v[0])&lt;br /&gt;
&lt;br /&gt;
        for i in range(1, nc + 1):&lt;br /&gt;
            t[i] = 1&lt;br /&gt;
&lt;br /&gt;
        p = p - 2 * nc&lt;br /&gt;
        t[0] = nc&lt;br /&gt;
        cc = 1&lt;br /&gt;
        egalcif = 1&lt;br /&gt;
        while p &amp;gt; 0 and cc &amp;lt;= t[0]:&lt;br /&gt;
            dmin = 10&lt;br /&gt;
            cifra = 1&lt;br /&gt;
            dmax = 0&lt;br /&gt;
&lt;br /&gt;
            for i in range(2, 10):&lt;br /&gt;
                if t[0] == v[0] and egalcif == 1:&lt;br /&gt;
                    if i &amp;lt;= v[cc] and abs(i - v[cc]) &amp;lt;= dmin and p - pw[i] + pw[1] &amp;gt;= 0:&lt;br /&gt;
                        cifra = i&lt;br /&gt;
                        dmin = abs(i - v[cc])&lt;br /&gt;
                if t[0] &amp;lt; v[0] or egalcif == 0:&lt;br /&gt;
                    if i &amp;gt;= dmax and p - pw[i] + pw[1] &amp;gt;= 0:&lt;br /&gt;
                        cifra = i&lt;br /&gt;
                        dmax = i&lt;br /&gt;
&lt;br /&gt;
            if v[cc] - cifra != 0:&lt;br /&gt;
                egalcif = 0&lt;br /&gt;
&lt;br /&gt;
            p += pw[1]&lt;br /&gt;
            p -= pw[cifra]&lt;br /&gt;
            t[cc] = cifra&lt;br /&gt;
            cc += 1&lt;br /&gt;
&lt;br /&gt;
        for i in range(1, t[0] + 1):&lt;br /&gt;
            g.write(str(t[i]))&lt;br /&gt;
&lt;br /&gt;
        g.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
&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>Corjuc Eunice</name></author>
	</entry>
</feed>