<?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=2298_-_Magnitudine</id>
	<title>2298 - Magnitudine - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=2298_-_Magnitudine"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2298_-_Magnitudine&amp;action=history"/>
	<updated>2026-05-01T06:50: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=2298_-_Magnitudine&amp;diff=9355&amp;oldid=prev</id>
		<title>Hotico Iulia Denisa: /* Lipește codul aici */</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2298_-_Magnitudine&amp;diff=9355&amp;oldid=prev"/>
		<updated>2024-01-10T19:14:05Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Lipește codul aici&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 19:14, 10 January 2024&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-l30&quot;&gt;Line 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 30:&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;import sys&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;import sys&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;sys.stdin = open(&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;magnitudine.in&lt;/del&gt;.txt&#039;, &#039;r&#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;sys.stdin = open(&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;magnitudinein&lt;/ins&gt;.txt&#039;, &#039;r&#039;)&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;sys.stdout = open(&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;magnitudine.out&lt;/del&gt;.txt&#039;, &#039;w&#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;sys.stdout = open(&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;magnitudineout&lt;/ins&gt;.txt&#039;, &#039;w&#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;n, k = map(int, input().split())&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;n, k = map(int, input().split())&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Hotico Iulia Denisa</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=2298_-_Magnitudine&amp;diff=8079&amp;oldid=prev</id>
		<title>Raul: Pagină nouă:  = Cerința = În această problemă veţi primi două numere natural &lt;code&gt;N&lt;/code&gt;, şi &lt;code&gt;K&lt;/code&gt;. Definim magnitudinea unui număr ca fiind diferenţa dintre cifra maximă şi cifra minimă ale lui. De exemplu, magnitudinea lui &lt;code&gt;9748&lt;/code&gt; este &lt;code&gt;9&lt;/code&gt; – &lt;code&gt;4&lt;/code&gt; = &lt;code&gt;5&lt;/code&gt;.  Eliminaţi maxim &lt;code&gt;K&lt;/code&gt; cifre din numărul &lt;code&gt;N&lt;/code&gt;, astfel încât magnitudinea numărului obţinut să fie cât mai mică.  = Date de intrare = În fiș...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2298_-_Magnitudine&amp;diff=8079&amp;oldid=prev"/>
		<updated>2023-12-14T13:32:01Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă:  = Cerința = În această problemă veţi primi două numere natural &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, şi &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;. Definim magnitudinea unui număr ca fiind diferenţa dintre cifra maximă şi cifra minimă ale lui. De exemplu, magnitudinea lui &amp;lt;code&amp;gt;9748&amp;lt;/code&amp;gt; este &amp;lt;code&amp;gt;9&amp;lt;/code&amp;gt; – &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt;.  Eliminaţi maxim &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; cifre din numărul &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, astfel încât magnitudinea numărului obţinut să fie cât mai mică.  = Date de intrare = În fiș...&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;
În această problemă veţi primi două numere natural &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, şi &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt;. Definim magnitudinea unui număr ca fiind diferenţa dintre cifra maximă şi cifra minimă ale lui. De exemplu, magnitudinea lui &amp;lt;code&amp;gt;9748&amp;lt;/code&amp;gt; este &amp;lt;code&amp;gt;9&amp;lt;/code&amp;gt; – &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt; = &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Eliminaţi maxim &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; cifre din numărul &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;, astfel încât magnitudinea numărului obţinut să fie cât mai mică.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
În fișierul &amp;lt;code&amp;gt;magnitudine.in&amp;lt;/code&amp;gt; se află pe prima linie numerele &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; si &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; separate prin spaţii.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Afișați în fișierul &amp;lt;code&amp;gt;magnitudine.out&amp;lt;/code&amp;gt; magnitudinea minimă care se poate obţine după eliminarea a &amp;lt;code&amp;gt;K&amp;lt;/code&amp;gt; cifre ale lui &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ N ≤ 10&amp;lt;sup&amp;gt;18&amp;lt;/sup&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* pentru teste în valoare de 30 puncte, &amp;lt;code&amp;gt;K = 0&amp;lt;/code&amp;gt;&lt;br /&gt;
* pentru teste în valoare de 30 puncte, &amp;lt;code&amp;gt;K = 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* pentru teste în valoare de 40 puncte, &amp;lt;code&amp;gt;K = 2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Exemplu 1: =&lt;br /&gt;
&amp;lt;code&amp;gt;magnitudine.in&amp;lt;/code&amp;gt;&lt;br /&gt;
 9748 1&lt;br /&gt;
&amp;lt;code&amp;gt;magnitudine.out&amp;lt;/code&amp;gt;&lt;br /&gt;
 2&lt;br /&gt;
&lt;br /&gt;
== Încărcare soluție ==&lt;br /&gt;
&lt;br /&gt;
=== Lipește codul aici ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
sys.stdin = open(&amp;#039;magnitudine.in.txt&amp;#039;, &amp;#039;r&amp;#039;)&lt;br /&gt;
sys.stdout = open(&amp;#039;magnitudine.out.txt&amp;#039;, &amp;#039;w&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
n, k = map(int, input().split())&lt;br /&gt;
p = 0&lt;br /&gt;
a = []&lt;br /&gt;
while n:&lt;br /&gt;
    a.append(n % 10)&lt;br /&gt;
    n //= 10&lt;br /&gt;
    p += 1&lt;br /&gt;
a.sort()&lt;br /&gt;
if k == 0:&lt;br /&gt;
    print(a[p-1] - a[0])&lt;br /&gt;
elif k == 1:&lt;br /&gt;
    if a[p-2] - a[0] &amp;lt;= a[p-1] - a[1]:&lt;br /&gt;
        print(a[p-2] - a[0])&lt;br /&gt;
    else:&lt;br /&gt;
        print(a[p-1] - a[1])&lt;br /&gt;
else:&lt;br /&gt;
    if a[p-3] - a[0] &amp;lt;= a[p-1] - a[2] and a[p-3] - a[0] &amp;lt;= a[p-2] - a[1]:&lt;br /&gt;
        print(a[p-3] - a[0])&lt;br /&gt;
    elif a[p-1] - a[2] &amp;lt;= a[p-3] - a[0] and a[p-1] - a[2] &amp;lt;= a[p-2] - a[1]:&lt;br /&gt;
        print(a[p-1] - a[2])&lt;br /&gt;
    else:&lt;br /&gt;
        print(a[p-2] - a[1])&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Raul</name></author>
	</entry>
</feed>