<?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=3752_-_Cvintete</id>
	<title>3752 - Cvintete - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=3752_-_Cvintete"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=3752_-_Cvintete&amp;action=history"/>
	<updated>2026-05-01T06:49:33Z</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=3752_-_Cvintete&amp;diff=9052&amp;oldid=prev</id>
		<title>Miawinator: Pagină nouă: Se consideră numerele naturale nenule &lt;code&gt;N&lt;/code&gt; și &lt;code&gt;D&lt;/code&gt; urmate de o secvență &lt;code&gt;S&lt;/code&gt; de &lt;code&gt;N&lt;/code&gt; numere naturale nenule ordonate crescător, indexate de la &lt;code&gt;1&lt;/code&gt; la &lt;code&gt;N&lt;/code&gt;.  = Cerința = Să se determine numărul de cvintete de indici &lt;code&gt;(i1, i2, i3, i4, i5)&lt;/code&gt; ce verifică relațiile:  * &lt;code&gt;a • b • c = D&lt;/code&gt; * &lt;code&gt;a • x2&lt;/code&gt; &lt;code&gt;+ b • y2&lt;/code&gt; &lt;code&gt;= c2&lt;/code&gt; * &lt;code&gt;a &lt; b &lt; c&lt;/code&gt; * &lt;code&gt;x...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=3752_-_Cvintete&amp;diff=9052&amp;oldid=prev"/>
		<updated>2024-01-05T01:43:50Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: Se consideră numerele naturale nenule &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;D&amp;lt;/code&amp;gt; urmate de o secvență &amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; de &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; numere naturale nenule ordonate crescător, indexate 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;.  = Cerința = Să se determine numărul de cvintete de indici &amp;lt;code&amp;gt;(i1, i2, i3, i4, i5)&amp;lt;/code&amp;gt; ce verifică relațiile:  * &amp;lt;code&amp;gt;a • b • c = D&amp;lt;/code&amp;gt; * &amp;lt;code&amp;gt;a • x2&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;+ b • y2&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;= c2&amp;lt;/code&amp;gt; * &amp;lt;code&amp;gt;a &amp;lt; b &amp;lt; c&amp;lt;/code&amp;gt; * &amp;lt;code&amp;gt;x...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Se consideră numerele naturale nenule &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;D&amp;lt;/code&amp;gt; urmate de o secvență &amp;lt;code&amp;gt;S&amp;lt;/code&amp;gt; de &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; numere naturale nenule ordonate crescător, indexate 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;.&lt;br /&gt;
&lt;br /&gt;
= Cerința =&lt;br /&gt;
Să se determine numărul de cvintete de indici &amp;lt;code&amp;gt;(i1, i2, i3, i4, i5)&amp;lt;/code&amp;gt; ce verifică relațiile:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;a • b • c = D&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;a • x2&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;+ b • y2&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;= c2&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;a &amp;lt; b &amp;lt; c&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;x ≠ y&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
unde am notat cu &amp;lt;code&amp;gt;a = S[i1]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;b = S[i2]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;c = S[i3]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;x = S[i4]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;y = S[i5]&amp;lt;/code&amp;gt;. Rezultatul se va afișa modulo &amp;lt;code&amp;gt;1.000.000.007&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;input.txt&amp;lt;/code&amp;gt; conține pe prima linie două numere naturale nenule &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;D&amp;lt;/code&amp;gt; cu semnificația&lt;br /&gt;
&lt;br /&gt;
din enunț. Pe următoarea linie se vor afla &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; numere naturale nenule ordonate crescător.&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 un singur număr natural care reprezintă rezultatul cerinței, modulo &amp;lt;code&amp;gt;1.000.000.007&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Exemplul 1 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
4 6&lt;br /&gt;
&lt;br /&gt;
1 2 3 3&lt;br /&gt;
&lt;br /&gt;
output.txt:&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
Explicație:&lt;br /&gt;
&lt;br /&gt;
Cvintetele care respectă cerința sunt: &amp;lt;code&amp;gt;(1, 2, 3, 1, 2)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(1, 2, 4, 1, 2)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Exemplul 2 ==&lt;br /&gt;
input.txt:&lt;br /&gt;
&lt;br /&gt;
10 60&lt;br /&gt;
&lt;br /&gt;
1 2 3 4 4 5 6 8 10 12&lt;br /&gt;
&lt;br /&gt;
output.txt:&lt;br /&gt;
&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
Explicație:&lt;br /&gt;
&lt;br /&gt;
Cvintetele care respectă cerința sunt: &amp;lt;code&amp;gt;(1, 6, 10, 8, 4)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(1, 6, 10, 8, 5)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(1, 7, 9, 2, 4)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(1, 7, 9, 2, 5)&amp;lt;/code&amp;gt;&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;
import math&lt;br /&gt;
&lt;br /&gt;
M = 1000000007&lt;br /&gt;
N = 25000&lt;br /&gt;
P = 1235789&lt;br /&gt;
&lt;br /&gt;
def gcd(A, B):&lt;br /&gt;
    r = A % B&lt;br /&gt;
    while r != 0:&lt;br /&gt;
        A = B&lt;br /&gt;
        B = r&lt;br /&gt;
        r = A % B&lt;br /&gt;
    return B&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 infile, open(&amp;quot;output.txt&amp;quot;, &amp;quot;w&amp;quot;) as outfile:&lt;br /&gt;
        n, d = map(int, infile.readline().split())&lt;br /&gt;
        f = [0] * (N + 1)&lt;br /&gt;
        di = [0] * (N + 1)&lt;br /&gt;
        pp = [0] * (N + 1)&lt;br /&gt;
        v = [0] * (P + 1)&lt;br /&gt;
        k = 0&lt;br /&gt;
        m = 0&lt;br /&gt;
&lt;br /&gt;
        l=list(map(int, infile.readline().split()))&lt;br /&gt;
&lt;br /&gt;
        for i in range(n):&lt;br /&gt;
            x = l[i]&lt;br /&gt;
            f[x] += 1&lt;br /&gt;
            if x &amp;gt; m:&lt;br /&gt;
                m = x&lt;br /&gt;
&lt;br /&gt;
        for i in range(1, m + 1):&lt;br /&gt;
            if (d % i == 0) and (f[i] &amp;gt; 0):&lt;br /&gt;
                k += 1&lt;br /&gt;
                di[k] = i&lt;br /&gt;
            pp[i] = i * i&lt;br /&gt;
            v[pp[i] % P] = i&lt;br /&gt;
&lt;br /&gt;
        sol = 0&lt;br /&gt;
&lt;br /&gt;
        for i in range(1, k - 1):&lt;br /&gt;
            a = di[i]&lt;br /&gt;
            for j in range(i + 1, k):&lt;br /&gt;
                b = di[j]&lt;br /&gt;
                e = a * b&lt;br /&gt;
                if d % e == 0:&lt;br /&gt;
                    c = d // e&lt;br /&gt;
                    if c &amp;gt; b and c &amp;lt;= m and f[c] &amp;gt; 0:&lt;br /&gt;
                        nr = f[a] * f[b] * f[c]&lt;br /&gt;
                        w = c * c&lt;br /&gt;
                        dc = gcd(a, b)&lt;br /&gt;
                        if w % dc == 0:&lt;br /&gt;
                            l = int(math.sqrt(w / b))&lt;br /&gt;
                            for u in range(1, l + 1):&lt;br /&gt;
                                if (w - b * pp[u]) % a == 0:&lt;br /&gt;
                                    z = (w - b * pp[u]) // a&lt;br /&gt;
                                    h = v[z % P]&lt;br /&gt;
                                    if h * h == z and h != u and h &amp;lt;= m:&lt;br /&gt;
                                        sol += nr * f[u] * f[h]&lt;br /&gt;
&lt;br /&gt;
        outfile.write(str(sol % M) + &amp;quot;\n&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Miawinator</name></author>
	</entry>
</feed>