0% found this document useful (0 votes)
6 views3 pages

Filozof

Uploaded by

St3fKe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Filozof

Uploaded by

St3fKe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

public class Program


{
public static void Main(string[] args)
{
/*for i from 1 to N:
if i == 1
X[i] = (A * S + B) mod M
else
X[i] = (A * YY[i-1] + B) mod M
Y[i] = (A * X[i] + B) mod M
XX[i] = (A * Y[i] + B) mod M
YY[i] = (A * XX[i] + B) mod M

if X[i] == XX[i]
XX[i] = XX[i] + 1
if X[i] > XX[i]:
swap(X[i], XX[i])

if Y[i] == YY[i]
YY[i] = YY[i] + 1
if Y[i] > YY[i]
swap(Y[i], YY[i])*/
ulong i, j, n, k, m, a, b, s, temp, br = 0, minsir, minvis;

String s1;
String[] s2;
s1 = Console.ReadLine();
s2 = s1.Split(' ');
n = (ulong)Convert.ToInt32(s2[0]);
k = (ulong)Convert.ToInt32(s2[1]);
m = (ulong)Convert.ToInt32(s2[2]);
a = (ulong)Convert.ToInt32(s2[3]);
b = (ulong)Convert.ToInt32(s2[4]);
s = (ulong)Convert.ToInt32(s2[5]);
ulong[] x = new ulong[10000000], y = new ulong[10000000], xx = new
ulong[10000000], yy = new ulong[10000000], xd = new ulong[10000000], yd = new
ulong[10000000], xg = new ulong[10000000], yg = new ulong[10000000], visina = new
ulong[n], sirina = new ulong[n];

for (i = 0; i < n; i++)


{
if (i == 0) { x[i] = (a * s + b) % m; }
else x[i] = (a * yy[i - 1] + b) % m;
y[i] = (a * x[i] + b) % m;
xx[i] = (a * y[i] + b) % m;
yy[i] = (a * xx[i] + b) % m;
if (x[i] == xx[i]) xx[i] = xx[i] + 1;
if (x[i] > xx[i])
{
temp = x[i];
x[i] = xx[i];
xx[i] = temp;
}
if (y[i] == yy[i]) yy[i] = yy[i] + 1;
if (y[i] > yy[i])
{
temp = y[i];
y[i] = yy[i];
yy[i] = temp;
}
}
/*for(i=0; i<n; i++)
{
Console.WriteLine(x[i] + " " + y[i] + " " + xx[i] + " " + yy[i] + "
");
}*/

for (i = 1; i < k; i++)


{
xd[br] = least(x, 0, i);
yd[br] = least(y, 0, i);
xg[br] = most(xx, 0, i);
yg[br] = most(yy, 0, i);
br++;
//Console.WriteLine(xd[br-1] + " " + yd[br-1] + " " + xg[br-1] + " " +
yg[br-1] + " ");
}

for (i = 0; i < n; i++)


{
xd[br] = least(x, i, k + i);
yd[br] = least(y, i, k + i);
xg[br] = most(xx, i, k + i);
yg[br] = most(yy, i, k + i);
br++;
//Console.WriteLine(xd[br - 1] + " " + yd[br - 1] + " " + xg[br - 1] +
" " + yg[br - 1] + " ");
}
for (i = 0; i < n; i++)
{

visina[i] = xg[i] - xd[i];


sirina[i] = yg[i] - yd[i];

/*Console.WriteLine(i +" visina: " + visina[i] + " ");


Console.WriteLine(i +" sirina: " + sirina[i] + " ");*/
}
minvis = visina[0];
minsir = sirina[0];
for (i = 1; i < n; i++)
{
if (visina[i] > minvis)
{
minvis = visina[i];
//Console.WriteLine(minvis + " <- minvis ");
}
if (sirina[i] > minsir)
{
minsir = sirina[i];
}

}
Console.WriteLine(minvis + " " + minsir);
}
public static ulong least(ulong[] x, ulong i1, ulong i2)
{
ulong min;
min = x[i1];
for (ulong i = i1 + 1; i < i2; i++)
{
if (x[i] < min)
{
min = x[i];
}
}
return min;
}
public static ulong most(ulong[] x, ulong i1, ulong i2)
{
ulong max;
max = x[i1];
for (ulong i = i1 + 1; i < i2; i++)
{
if (x[i] > max)
{
max = x[i];
}
}
return max;
}
}
https://petlja.org/biblioteka/r/problemi/takmicenja-srednje-skole/04_filozof

You might also like