<?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=0950_-_Cerc_3</id>
	<title>0950 - Cerc 3 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=0950_-_Cerc_3"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0950_-_Cerc_3&amp;action=history"/>
	<updated>2026-05-01T04:36:02Z</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=0950_-_Cerc_3&amp;diff=9718&amp;oldid=prev</id>
		<title>Aurelia Raluca: Pagină nouă: == Enunț == Se consideră pe axa &lt;code&gt;Ox&lt;/code&gt; din plan n puncte distincte reprezentând centrele a &lt;code&gt;n&lt;/code&gt; cercuri numerotate cu numerele distincte de la &lt;code&gt;1&lt;/code&gt; la &lt;code&gt;n&lt;/code&gt;. Pentru fiecare cerc &lt;code&gt;k&lt;/code&gt; se cunosc abscisa &lt;code&gt;xk&lt;/code&gt; a centrului său şi raza sa &lt;code&gt;rk&lt;/code&gt;.  = Cerința = Să se scrie un program care să determine numărul &lt;code&gt;y&lt;/code&gt; maxim de cercuri exterioare două câte două dintre cele &lt;code&gt;n&lt;/code&gt;.  = Date de...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=0950_-_Cerc_3&amp;diff=9718&amp;oldid=prev"/>
		<updated>2024-03-23T00:19:30Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: == Enunț == Se consideră pe axa &amp;lt;code&amp;gt;Ox&amp;lt;/code&amp;gt; din plan n puncte distincte reprezentând centrele a &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; cercuri numerotate cu numerele distincte de la &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; la &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;. Pentru fiecare cerc &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; se cunosc abscisa &amp;lt;code&amp;gt;xk&amp;lt;/code&amp;gt; a centrului său şi raza sa &amp;lt;code&amp;gt;rk&amp;lt;/code&amp;gt;.  = Cerința = Să se scrie un program care să determine numărul &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; maxim de cercuri exterioare două câte două dintre cele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;.  = Date de...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Enunț ==&lt;br /&gt;
Se consideră pe axa &amp;lt;code&amp;gt;Ox&amp;lt;/code&amp;gt; din plan n puncte distincte reprezentând centrele a &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; cercuri numerotate cu numerele distincte de la &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; la &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;. Pentru fiecare cerc &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt; se cunosc abscisa &amp;lt;code&amp;gt;xk&amp;lt;/code&amp;gt; a centrului său şi raza sa &amp;lt;code&amp;gt;rk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Cerința =&lt;br /&gt;
Să se scrie un program care să determine numărul &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; maxim de cercuri exterioare două câte două dintre cele &amp;lt;code&amp;gt;n&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;cerc3IN.txt&amp;lt;/code&amp;gt; conține pe prima linie pe prima linie, o valoare naturală n, reprezentând numărul de cercuri, iar pe următoarele n linii câte două numere naturale, separate printr-un spaţiu, care reprezintă abscisa &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt; a centrului primului cerc şi raza sa &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;,…, abscisa &amp;lt;code&amp;gt;xn&amp;lt;/code&amp;gt; a centrului celui de-al &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;-lea cerc şi raza sa &amp;lt;code&amp;gt;rn&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;cerc3OUT.txt&amp;lt;/code&amp;gt; va conține o linie pe care va fi scris numărul natural &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; reprezentând numărul maxim de cercuri exterioare ale căror centre sunt situate pe axa &amp;lt;code&amp;gt;Ox&amp;lt;/code&amp;gt;. În cazul în care restricțiile nu sunt îndeplinite, se va afișa mesajul &amp;quot;Datele nu corespund restrictiilor impuse&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* numerele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;x2&amp;lt;/code&amp;gt;,…,&amp;lt;code&amp;gt;xn&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;,…, &amp;lt;code&amp;gt;rn&amp;lt;/code&amp;gt; sunt numere naturale&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ n ≤ 300&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤&amp;lt;/code&amp;gt;  &amp;lt;code&amp;gt;x1&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;x2&amp;lt;/code&amp;gt;,…,&amp;lt;code&amp;gt;xn&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;≤ 150&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;,…, &amp;lt;code&amp;gt;rn&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;≤ 70&amp;lt;/code&amp;gt;&lt;br /&gt;
* dacă două cercuri, dintre cele &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;, au centrele în acelaşi punct de pe axa &amp;lt;code&amp;gt;Ox&amp;lt;/code&amp;gt;, atunci razele lor sunt distincte&lt;br /&gt;
* două cercuri sunt exterioare dacă nu au niciun punct comun şi nici interioarele lor nu au puncte comune&lt;br /&gt;
&lt;br /&gt;
= Exemplul 1: =&lt;br /&gt;
&amp;lt;code&amp;gt;cerc3IN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 8&lt;br /&gt;
 3 1&lt;br /&gt;
 1 4&lt;br /&gt;
 8 1&lt;br /&gt;
 11 2&lt;br /&gt;
 15 2&lt;br /&gt;
 16 6&lt;br /&gt;
 21 2&lt;br /&gt;
 21 1&lt;br /&gt;
&amp;lt;code&amp;gt;cerc3OUT.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 4&lt;br /&gt;
&lt;br /&gt;
= Explicație =&lt;br /&gt;
Numărul maxim de cercuri exterioare două câte două este &amp;lt;code&amp;gt;y=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Exemplul 2: ==&lt;br /&gt;
&amp;lt;code&amp;gt;cerc3IN.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
 301&lt;br /&gt;
 3 1&lt;br /&gt;
 1 4&lt;br /&gt;
 8 1&lt;br /&gt;
 11 2&lt;br /&gt;
 15 2&lt;br /&gt;
 16 6&lt;br /&gt;
 21 2&lt;br /&gt;
 21 1&lt;br /&gt;
&amp;lt;code&amp;gt;cerc3OUT.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;python3&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
def verificare_restrictii(n, cercuri):&lt;br /&gt;
    if n &amp;lt; 1 or n &amp;gt; 300:&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
    for x, r in cercuri:&lt;br /&gt;
        if x &amp;lt; 1 or x &amp;gt; 150 or r &amp;lt; 1 or r &amp;gt; 70:&lt;br /&gt;
            return False&lt;br /&gt;
&lt;br /&gt;
    return True&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    with open(&amp;quot;cerc3IN.txt&amp;quot;, &amp;quot;r&amp;quot;) as f, open(&amp;quot;cerc3OUT.txt&amp;quot;, &amp;quot;w&amp;quot;) as g:&lt;br /&gt;
        n_line = f.readline().strip()&lt;br /&gt;
        &lt;br /&gt;
        if not n_line:&lt;br /&gt;
            g.write(&amp;quot;Datele din fisierul de intrare lipsesc sau sunt incomplete.&amp;quot;)&lt;br /&gt;
            return&lt;br /&gt;
&lt;br /&gt;
        try:&lt;br /&gt;
            n = int(n_line)&lt;br /&gt;
        except ValueError:&lt;br /&gt;
            g.write(&amp;quot;Numarul de cercuri este invalid.&amp;quot;)&lt;br /&gt;
            return&lt;br /&gt;
&lt;br /&gt;
        cercuri = []&lt;br /&gt;
        for line in f:&lt;br /&gt;
            values = line.split()&lt;br /&gt;
            if len(values) != 2:&lt;br /&gt;
                g.write(&amp;quot;Datele din fisierul de intrare sunt incomplete sau au format invalid.&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
            &lt;br /&gt;
            try:&lt;br /&gt;
                o, r = map(int, values)&lt;br /&gt;
            except ValueError:&lt;br /&gt;
                g.write(&amp;quot;Coordonatele sau razele cercurilor sunt invalide.&amp;quot;)&lt;br /&gt;
                return&lt;br /&gt;
            &lt;br /&gt;
            cercuri.append((o, r))&lt;br /&gt;
&lt;br /&gt;
        if not verificare_restrictii(n, cercuri):&lt;br /&gt;
            g.write(&amp;quot;Datele nu corespund restrictiilor impuse&amp;quot;)&lt;br /&gt;
            return&lt;br /&gt;
&lt;br /&gt;
        cercuri = [(o - r, o + r) for o, r in cercuri]&lt;br /&gt;
        cercuri.sort(key=lambda x: x[1])&lt;br /&gt;
&lt;br /&gt;
        nr = 1&lt;br /&gt;
        x = cercuri[0][1]&lt;br /&gt;
        for i in range(1, n):&lt;br /&gt;
            if x &amp;lt; cercuri[i][0]:&lt;br /&gt;
                nr += 1&lt;br /&gt;
                x = cercuri[i][1]&lt;br /&gt;
&lt;br /&gt;
        g.write(str(nr))&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>Aurelia Raluca</name></author>
	</entry>
</feed>