This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Задача: дано натуральное число N. Необходимо найти наименьшее натуральное число, в ктр произведение его цифр было бы равно N. Если такого числа не существует, вывести -1. | |
Входные данные: N - натуральное число от 1 до 10^9. | |
Вывод: наименьшее натуральное число, произведение цифр ктр было бы равно N. -1 - если такого числа нет. | |
Пример: | |
N = 11; Answer = -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Задача: есть массив целых чисел. В нем необходимо определить подмножество с максимальным модулем суммы чисел входящих в него. | |
Входные данные: arr - массив целых чисел, размер массива от 1 до 10^4. | |
Вывод: подмножество чисел исходного массива, ктр образуют множество с максмимальным модулем суммы. Если есть несколько множеств с одинаковым модулем суммы, то выводите любое. | |
Пример: [-1, 2, -1, 3, -4] | |
Answer: { -1, -1, -4 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(loop for i from 1 to 10 do | |
(mapcar (lambda (x) (format t "~d x ~d = ~d~%" i x (* x i))) | |
'(1 2 3 4 5 6 7 8 9 10)) | |
(terpri))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun factorize(n) | |
(setq facts '() d 2) | |
(loop while (<= (* d d) n) do | |
(loop while (= 0 (rem n d)) do | |
(setq n (/ n d)) | |
(setq facts (push d facts))) | |
(setq d (1+ d))) | |
(when (/= n 1) | |
(setq facts (push n facts))) | |
facts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun div(n d) | |
(multiple-value-bind (q r) (floor n d) q)) | |
(defun per(n) | |
(if (= n (rem n 10)) | |
(format t "~d~%" n) | |
(progn | |
(format t "~d->" n) | |
(setq mul 1) | |
(loop while (> n 0) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar *n* (read)) | |
(defvar *counter* 0) | |
(do () ((= *n* 1) *n*) | |
(setf *counter* (1+ *counter*)) | |
(format t "~d->~d~%" | |
*n* | |
(if (= (mod *n* 2) 0) | |
(let ((n1 (/ *n* 2))) (setf *n* n1) n1) | |
(let ((n1 (1+ (* *n* 3)))) (setf *n* n1) n1)))) | |
(format t "Loops in ~d steps~%" *counter*) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun spiral-matrix (mat n &optional (x 0) (y 0) (k 1) (dx 1) (dy 0) (defval 0)) | |
;; Рекурсивная функция для создания спиральной квадратной матрицы (по часовой стрелке) | |
;; mat - массив n*n заполненый изчально defval | |
;; никаких проверок нет, если mat или n кривые будет ошибка | |
(if (<= k (* n n)) | |
(progn | |
(setf (aref mat y x) k) | |
(let ((x1 (+ x dx)) (y1 (+ y dy))) | |
(if (and | |
(>= x1 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def selection_sort(a: list): | |
length = len(a) | |
for i in range(length): | |
current_min_i = i | |
current_min = a[i] | |
for j in range(i + 1, length): | |
if a[j] < current_min: | |
current_min = a[j] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
P=monty | |
OBJECTS= | |
CFLAGS = -g -Iinclude -Wall `pkg-config --cflags libsodium` | |
LDLIBS= `pkg-config --libs libsodium` | |
CC=cc | |
$(P): $(OBJECTS) | |
clean: | |
-rm $(OBJECTS) $(P) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import sys | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
def get_rgb(r: int, g: int, b: int): | |
if 0 <= r <= 255 and 0 <= g <= 255 and 0 <= b <= 255: | |
return '#%02x%02x%02x' % (r, g, b) |