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
from fractions import Fraction | |
from math import atan2, pi | |
EPS = 1e-8 | |
MAX_X = 2 ** 20 | |
def _box_intersect(a, b, c, d): | |
if a > b: a, b = b, a | |
if c > d: c, d = d, c |
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
from decimal import getcontext, Decimal as D | |
from collections import Counter | |
N = 100000 | |
getcontext().prec = N + 10 | |
a, b, t, p, d = D('1'), D('1') / D('2').sqrt(), D('0.25'), D('1'), D('0.5') | |
for i in range(N.bit_length()): | |
a, b, t, p = (a + b) * d, (a * b).sqrt(), t - p * (a - (a + b) * d) ** 2, 2 * p | |
res = str((a + b) ** 2 / (D('4') * t)) | |
dg = res[2:N+2] | |
# print(res[0:N + 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
0кг за 0 взв. ( 1 реш) Решение: (120,), 0 = | |
1кг за 4 взв. ( 62 реш) Решение: (120,) -> []<120>[8] -> (56, 64) -> []<64>[56] -> (4, 56, 60) -> [8]<60>[56] -> (4, 6, 54, 56) -> [4]<54>[56] -> (1, 4, 6, 53, 56), 1 = 1 | |
2кг за 3 взв. ( 4 реш) Решение: (120,) -> []<120>[8] -> (56, 64) -> []<64>[56] -> (4, 56, 60) -> []<60>[56] -> (2, 4, 56, 58), 2 = 2 | |
3кг за 4 взв. ( 69 реш) Решение: (120,) -> []<120>[8] -> (56, 64) -> []<64>[56] -> (4, 56, 60) -> [8]<60>[56] -> (4, 6, 54, 56) -> [4]<56>[54] -> (3, 4, 6, 53, 54), 3 = 3 | |
4кг за 2 взв. ( 2 реш) Решение: (120,) -> []<120>[8] -> (56, 64) -> []<64>[56] -> (4, 56, 60), 4 = 4 | |
5кг за 4 взв. ( 82 реш) Решение: (120,) -> []<120>[8] -> (56, 64) -> []<64>[56] -> (4, 56, 60) -> []<56>[4,8] -> (4, 22, 34, 60) -> []<22>[4,8] -> (4, 5, 17, 34, 60), 5 = 5 | |
6кг за 3 взв. ( 5 реш) Решение: (120,) -> []<120>[8] -> (56, 64) -> []<64>[56] -> (4, 56, 60) -> [8]<60>[56] -> (4, 6, 54, 56), 6 = 6 | |
7кг за 4 взв. ( 81 реш) Решение: (120,) -> []<120>[8] -> (56, 64) -> []<64>[ |
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
from sympy import * | |
from sympy.abc import x | |
from sympy.vector import * | |
CoordSystem = CoordSys3D("C") | |
oX, oY, oZ = CoordSystem.i, CoordSystem.j, CoordSystem.k | |
A = oX * 14 # Удачным образом сторона 6-угольника равна радиусу окружости, в которую он вписан | |
B = (oX / 2 + oY * sqrt(3) / 2) * 14 | |
C = (-oX / 2 + oY * sqrt(3) / 2) * 14 | |
D, E, F = -A, -B, -C |
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
# Пример того, как можно делать запись вектороного произведения точек в виде cp[v, w], а не cp(v, w) | |
class Point: | |
"""Класс Точка""" | |
__slots__ = ['x', 'y'] | |
def __init__(self, x=0, y=0): | |
self.x = x | |
self.y = y | |
def __sub__(v, w): | |
return Point(v.x - w.x, v.y - w.y) | |
def __repr__(self): |
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
from gmpy2 import mpz | |
from timeit import timeit | |
from random import randint | |
from time import perf_counter | |
# Здесь мы создаём логарифмическую шкалу длин | |
from math import log10 | |
import numpy as np | |
int_lens = list(np.arange(1,100,1)) + list(np.logspace(2, log10(500000), num=150).astype(np.int32)) | |
int_lens = [int(x) for x in int_lens] |
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 re | |
import os | |
from Levenshtein import distance | |
def fmt_text(text): | |
"""Удалить бессмысленные различия""" | |
text = re.sub(r'[^а-я\s]', '', text.lower()) # Удаляем всё, кроме русских букв и пробелов | |
text = re.sub(r'\s+', ' ', text) # Удаляем длинные пробелы | |
return text |
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 re | |
import os | |
html_path = 'Y:\\' | |
os.chdir(html_path) | |
stat = {'1.Н': (57,57), '1.1': (43,57), '1.2': (49,57), '1.3': (49,57), '1.4': (28,57), '1.5': (26,57), '1.6а': (37,57), '1.6б': (37,57), '1.6в': (37,57), '1.6г': (37,57), '1.6д': (37,57), '1.7': (28,57), '1.8': (12,57), '1.9': (8,57), '1.10': (6,57), '1.11а': (6,57), '1.11б': (5,57), '1.12': (7,57), '1.13': (6,57), '1.14': (8,57), '2.Н': (73,73), '2.1': (49,73), '2.2а': (59,73), '2.2б': (58,73), '2.2в': (63,73), '2.3а': (43,73), '2.3б': (9,73), '2.4а': (51,73), '2.4б': (31,73), '2.5а': (8,73), '2.5б': (4,73), '2.6': (42,73), '2.7': (34,73), '2.8': (11,73), '2.9': (2,73), '2.10': (2,73), '2.11а': (2,73), '2.11б': (2,73), '2.12': (2,73), '3.Н': (73,73), '3.1': (44,73), '3.2': (56,73), '3.3а': (61,73), '3.3б': (49,73), '3.3в': (42,73), '3.4': (45,73), '3.5': (37,73), '3.6': (30,73), '3.7': (35,73), '3.8': (8,73), '3.9': (6,73), '3.10': (7,73), '3.11а': (2,73), '3.11б': (1,73), '4.Н': (100,100), '4.1': (54,100), '4.2': (55,100), '4.3': (46,100), '4.4': |
NewerOlder