rows_N = int(input("Введите количество строк N (N>=1): "))
if rows_N >= 1:
column_K = int(input("Введите количество столбцов K (K>=3): "))
if column_K >= 3:
mas = [[0 for j in range(column_K)] for i in range(rows_N)]
k = 0
n = 0
for k in range(1, column_K + 1):
for n in range(1, rows_N + 1):
if k == 1:
x = 1
else:
x = int(1 / 2 * k * (n**2 - n) - n**2 + 2 * n)
mas[n - 1][k - 1] = x
for row in mas:
print(", ".join([f"{x:>4}" for x in row]))
Введите количество строк N (N>=1): 15
Введите количество столбцов K (K>=3): 10
1, 1, 1, 1, 1, 1, 1, 1, 1, 1
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1, 3, 6, 9, 12, 15, 18, 21, 24, 27
1, 4, 10, 16, 22, 28, 34, 40, 46, 52
1, 5, 15, 25, 35, 45, 55, 65, 75, 85
1, 6, 21, 36, 51, 66, 81, 96, 111, 126
1, 7, 28, 49, 70, 91, 112, 133, 154, 175
1, 8, 36, 64, 92, 120, 148, 176, 204, 232
1, 9, 45, 81, 117, 153, 189, 225, 261, 297
1, 10, 55, 100, 145, 190, 235, 280, 325, 370
1, 11, 66, 121, 176, 231, 286, 341, 396, 451
1, 12, 78, 144, 210, 276, 342, 408, 474, 540
1, 13, 91, 169, 247, 325, 403, 481, 559, 637
1, 14, 105, 196, 287, 378, 469, 560, 651, 742
1, 15, 120, 225, 330, 435, 540, 645, 750, 855
from pathlib import Path
from skimage.metrics import structural_similarity
import cv2
import sys
path = Path(sys.argv[1])
ref = path / "reference standard.jpg"
imref = cv2.imread(ref.as_posix())
grayref = cv2.cvtColor(imref, cv2.COLOR_BGR2GRAY)
info = []
for m in path.iterdir():
if "reference standard.jpg" == m.name:
continue
im = cv2.imread(m.as_posix())
try:
gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
score, difference = structural_similarity(grayref, gray, full=True)
info.append((score, m.as_posix()))
except Exception:
print(f"{m} is bad")
for score, path in sorted(info):
print(score, path)
#include <iostream>
#include <vector>
class Data
{
private:
std::vector<int> elements;
std::size_t N;
public:
explicit Data(const std::size_t size)
: N{size}
{
elements.reserve(size);
elements.resize(size);
}
void fill()
{
std::cout << "Enter elements of array:" << std::endl;
auto index = std::size_t{};
for (auto &elem : elements)
std::cin >> elements.at(index++);
}
void process(const int x)
{
if (x == elements.at(0))
{
elements.at(0) = elements.at(N - 1);
elements.at(N - 1) = x;
std::cout << "Array after swapping first and last elements: ";
for (const auto &elem : elements)
std::cout << elem << " ";
}
else
std::cout << "Error";
}
};
int main()
{
auto x = int{};
auto n = std::size_t{};
std::cout << "Enter x: ";
std::cin >> x;
std::cout << "Enter Number of array elements: ";
std::cin >> n;
auto data = Data{n};
data.fill();
data.process(x);
return 0;
}
sage: 256893450689.divisors()
[1, 19, 13520707931, 256893450689]
sage: 252323674611367475532285533.divisors()
[1, 110933, 2267937467, 1002919711403, 251589107026711, 111256892345068999, 2274559189883690836201, 252323674611367475532285533]