Compare commits

..

No commits in common. "2aa12fbb6e37b00a54fd61417a7bdb3e45bc8cb1" and "2cb75e7bbcf4103fd091eca248fcc38d0fc9c663" have entirely different histories.

30 changed files with 0 additions and 774 deletions

8
.idea/.gitignore vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationEnabledOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
</component>
</project>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Algorithm.iml" filepath="$PROJECT_DIR$/.idea/Algorithm.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

View File

@ -1,22 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('WHERETHEREISAWILLTHEREISAWAY')
s_in = input()
# print(s_in)
# n = 97
# prime = [1] * (n + 1)
# prime[0] = prime[1] = 0
# for i in range(2, n + 1):
# j = i * i
# while j <= n:
# prime[j] = 0
# j += i
#
# print(prime)
# for idx, num in enumerate(prime):
# if num:
# print(idx)

View File

@ -1,10 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('WHERETHEREISAWILLTHEREISAWAY')
s_in = input()
l = list(s_in)
l.sort()
print(''.join(l))
assert 'AADDDDDGGOOOOPSTUUYYY' == 'AADDDDDGGOOOOPSTUUYYY'

View File

@ -1,83 +0,0 @@
import math
nums = [
[2, 1],
[3, 2],
[4, 1],
[5, 4],
[6, 5],
[7, 4],
[8, 1],
[9, 2],
[10, 9],
[11, 0],
[12, 5],
[13, 10],
[14, 11],
[15, 14],
[16, 9],
[17, 0],
[18, 11],
[19, 18],
[20, 9],
[21, 11],
[22, 11],
[23, 15],
[24, 17],
[25, 9],
[26, 23],
[27, 20],
[28, 25],
[29, 16],
[30, 29],
[31, 27],
[32, 25],
[33, 11],
[34, 17],
[35, 4],
[36, 29],
[37, 22],
[38, 37],
[39, 23],
[40, 9],
[41, 1],
[42, 11],
[43, 11],
[44, 33],
[45, 29],
[46, 15],
[47, 5],
[48, 41],
[49, 46],
]
def check(number):
for num, mod in nums:
a, b = divmod(number, num)
if b != mod:
print(f"{number} % {num} == {number % num} != {mod}")
return False
print(f"{number}: pass.")
return True
def lcm(a, b):
return a * b // math.gcd(a, b)
ans = 2022040920220409
check(ans)
# 中国剩余定理
ans = product = 1
for num, mod in nums:
while ans % num != mod:
ans += product
product = lcm(product, num)
print(f"{ans} % {num} == {mod}")
print(ans)
check(ans)

View File

@ -1,70 +0,0 @@
# for i in range(2, 50):
# print(f"[{i}, ],")
nums = [
[2, 1],
[3, 2],
[4, 1],
[5, 4],
[6, 5],
[7, 4],
[8, 1],
[9, 2],
[10, 9],
[11, 0],
[12, 5],
[13, 10],
[14, 11],
[15, 14],
[16, 9],
[17, 0],
[18, 11],
[19, 18],
[20, 9],
[21, 11],
[22, 11],
[23, 15],
[24, 17],
[25, 9],
[26, 23],
[27, 20],
[28, 25],
[29, 16],
[30, 29],
[31, 27],
[32, 25],
[33, 11],
[34, 17],
[35, 4],
[36, 29],
[37, 22],
[38, 37],
[39, 23],
[40, 9],
[41, 1],
[42, 11],
[43, 11],
[44, 33],
[45, 29],
[46, 15],
[47, 5],
[48, 41],
[49, 46],
]
ans = 11 * 17
while True:
flag = True
for num, mod in nums:
a, b = divmod(ans, num)
if b != mod:
flag = False
break
if flag:
print(ans)
break
ans += 11 * 17
if ans > pow(10, 17):
break
print(flag, ans)

View File

@ -1,69 +0,0 @@
# for i in range(2, 50):
# print(f"[{i}, ],")
import random
nums = [
[2, 1],
[3, 2],
[4, 1],
[5, 4],
[6, 5],
[7, 4],
[8, 1],
[9, 2],
[10, 9],
[11, 0],
[12, 5],
[13, 10],
[14, 11],
[15, 14],
[16, 9],
[17, 0],
[18, 11],
[19, 18],
[20, 9],
[21, 11],
[22, 11],
[23, 15],
[24, 17],
[25, 9],
[26, 23],
[27, 20],
[28, 25],
[29, 16],
[30, 29],
[31, 27],
[32, 25],
[33, 11],
[34, 17],
[35, 4],
[36, 29],
[37, 22],
[38, 37],
[39, 23],
[40, 9],
[41, 1],
[42, 11],
[43, 11],
[44, 33],
[45, 29],
[46, 15],
[47, 5],
[48, 41],
[49, 46],
]
def check(number):
for num, mod in nums:
a, b = divmod(number, num)
if b != mod:
# print(f"{number} % {num} != {mod}")
return False
print(f"{number}: pass.")
return True
while True:
check(random.randint(90909090, pow(10, 17)))

View File

@ -1,70 +0,0 @@
# for i in range(2, 50):
# print(f"[{i}, ],")
nums = [
[2, 1],
[3, 2],
[4, 1],
[5, 4],
[6, 5],
[7, 4],
[8, 1],
[9, 2],
[10, 9],
[11, 0],
[12, 5],
[13, 10],
[14, 11],
[15, 14],
[16, 9],
[17, 0],
[18, 11],
[19, 18],
[20, 9],
[21, 11],
[22, 11],
[23, 15],
[24, 17],
[25, 9],
[26, 23],
[27, 20],
[28, 25],
[29, 16],
[30, 29],
[31, 27],
[32, 25],
[33, 11],
[34, 17],
[35, 4],
[36, 29],
[37, 22],
[38, 37],
[39, 23],
[40, 9],
[41, 1],
[42, 11],
[43, 11],
[44, 33],
[45, 29],
[46, 15],
[47, 5],
[48, 41],
[49, 46],
]
ans = 11 * 17
while True:
flag = True
for num, mod in nums:
a, b = divmod(ans, num)
if b != mod:
flag = False
break
if flag:
print(ans)
break
ans += 11
if ans > pow(10, 17):
break
print(flag, ans)

View File

@ -1,70 +0,0 @@
# for i in range(2, 50):
# print(f"[{i}, ],")
nums = [
[2, 1],
[3, 2],
[4, 1],
[5, 4],
[6, 5],
[7, 4],
[8, 1],
[9, 2],
[10, 9],
[11, 0],
[12, 5],
[13, 10],
[14, 11],
[15, 14],
[16, 9],
[17, 0],
[18, 11],
[19, 18],
[20, 9],
[21, 11],
[22, 11],
[23, 15],
[24, 17],
[25, 9],
[26, 23],
[27, 20],
[28, 25],
[29, 16],
[30, 29],
[31, 27],
[32, 25],
[33, 11],
[34, 17],
[35, 4],
[36, 29],
[37, 22],
[38, 37],
[39, 23],
[40, 9],
[41, 1],
[42, 11],
[43, 11],
[44, 33],
[45, 29],
[46, 15],
[47, 5],
[48, 41],
[49, 46],
]
ans = 11 * 17
while True:
flag = True
for num, mod in nums:
a, b = divmod(ans, num)
if b != mod:
flag = False
break
if flag:
print(ans)
break
ans += 17
if ans > pow(10, 17):
break
print(flag, ans)

View File

@ -1,13 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('A5')
ans = [1189, 841]
s_in = input()
a = int(s_in[1:])
for i in range(a):
ans[0], ans[1] = ans[1], ans[0] // 2
print(ans[0])
print(ans[1])

View File

@ -1,13 +0,0 @@
import io
import sys
# import time
sys.stdin = io.StringIO('1000000\n5')
# start = time.time()
n, m = int(input()), int(input())
nums = [i for i in range(1, n + 1)]
nums.sort(key=lambda x: sum(map(int, list(str(x)))))
print(nums[m - 1])
# print(time.time() - start) # 2s

View File

@ -1,8 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('0 5 3 2 3 2\n')
d1, p1, q1, d2, p2, q2 = map(int, input().split())
# print(d1, p1, q1, d2, p2, q2)
print(p1 + q2)

View File

@ -1,33 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('edda')
sys.stdin = io.StringIO('sdfhhhhcvhhxcxnnnnshh')
s_in = f"EMPTY{input()}"
while True:
flag = True
del_index = set()
for i in range(5, len(s_in) - 1):
if s_in[i - 1] == s_in[i] and s_in[i] != s_in[i + 1]:
del_index.add(i)
del_index.add(i + 1)
elif s_in[i - 1] != s_in[i] and s_in[i] == s_in[i + 1]:
del_index.add(i - 1)
del_index.add(i)
if del_index:
flag = False
s = ''
for idx, ch in enumerate(s_in):
if idx in del_index:
continue
s += ch
s_in = s
if flag:
break
print(s_in if s_in == 'EMPTY' else s_in.replace('EMPTY', ''))

View File

@ -1,23 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('3') # 9
sys.stdin = io.StringIO('2022') # 593300958
# from itertools import permutations
#
# per = list(permutations(range(5)))
# print(per)
# 冒泡的交换次数公式
# print(len(per))
n = int(input())
ans = 0
per_num = 1
for i in range(1, n + 1):
for p in range(2, i + 1):
per_num *= p
ans += per_num // 2
ans %= 998244353
print(ans)

View File

@ -1,21 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('''3 6
10 5
9 2
8 1
''') # 47
import math
n, m = map(int, input().split())
nums = []
for i in range(n):
a, b = map(int, input().split())
for j in range(math.ceil(a / b)):
nums.append(a)
a -= b
nums.sort(reverse=True)
print(sum(nums[:m]))

View File

@ -1,23 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('''5 1
1 4 2 8 5
''') # 4
n, k = map(int, input().split())
nums = list(map(int, input().split()))
def cal_dp(arr):
dp = [1] * n
for i in range(1, n):
for j in range(i):
if arr[i] > arr[j] and dp[i] < dp[j] + 1:
dp[i] = dp[j] + 1
return dp
dp = cal_dp(nums)
print(max(dp) + k)

View File

@ -1,55 +0,0 @@
map_in = [
['A', 'E', 1],
['A', 'B', 2],
['A', 'C', 1],
['A', 'D', 1],
['A', 'E', 1],
['B', 'G', 1],
['B', 'J', 2],
['C', 'D', 3],
['C', 'G', 3],
['C', 'F', 3],
['D', 'G', 2],
['D', 'H', 1],
['D', 'I', 2],
['E', 'H', 1],
['E', 'I', 3],
['F', 'J', 1],
['F', 'G', 1],
['G', 'K', 2],
['G', 'I', 3],
['H', 'L', 2],
['H', 'I', 1],
['I', 'M', 3],
['J', 'S', 2],
['K', 'N', 1],
['K', 'L', 3],
['L', 'R', 1],
['L', 'M', 1],
['M', 'N', 2],
['M', 'Q', 1],
['M', 'S', 1],
['N', 'P', 1],
['Q', 'O', 1],
['O', 'R', 3],
['P', 'O', 1],
['R', 'S', 1],
]
def dp(now_dis, next_node):
for src, dst, dis in map_in:
if src == next_node:
now_dis += dis
if dst == 'S':
ans.append(now_dis)
else:
dp(now_dis, dst)
ans = []
for src, dst, dis in map_in:
if src == 'A':
dp(dis, dst)
print(min(ans))

View File

@ -1,59 +0,0 @@
map_in = [
['A', 'E', 1],
['A', 'B', 2],
['A', 'C', 1],
['A', 'D', 1],
['A', 'E', 1],
['B', 'G', 1],
['B', 'J', 2],
['C', 'D', 3],
['C', 'G', 3],
['C', 'F', 3],
['D', 'G', 2],
['D', 'H', 1],
['D', 'I', 2],
['E', 'H', 1],
['E', 'I', 3],
['F', 'J', 1],
['F', 'G', 1],
['G', 'K', 2],
['G', 'I', 3],
['H', 'L', 2],
['H', 'I', 1],
['I', 'M', 3],
['J', 'S', 2],
['K', 'N', 1],
['K', 'L', 3],
['L', 'R', 1],
['L', 'M', 1],
['M', 'N', 2],
['M', 'Q', 1],
['M', 'S', 1],
['N', 'P', 1],
['Q', 'O', 1],
['O', 'R', 3],
['P', 'O', 1],
['R', 'S', 1],
]
# 点的数量 数出来的
n = 19
# 初始化图 到自身到距离为0
fig = [[float('inf')] * n for _ in range(n)]
for i in range(n):
fig[i][i] = 0
# 构建好路 每个节点之间的距离
for src, dst, dis in map_in:
src, dst = ord(src) - ord('A'), ord(dst) - ord('A')
fig[src][dst] = fig[dst][src] = dis
# 从起点到每个节点到距离 S为最后一个节点 因为是字母序排序的
dis = [float('inf')] * n
dis[0] = 0
for i in range(n):
for j in range(n):
dis[j] = min(dis[j], dis[i] + fig[i][j])
print(dis)
print(dis[-1])

View File

@ -1,18 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('lanqiao')
s_in = input()
counter = [0] * 26
count_max = 0
for ch in s_in:
idx = ord(ch) - ord('a')
counter[idx] += 1
count_max = max(count_max, counter[idx])
for i in range(26):
if count_max == counter[i]:
print(chr(i + ord('a')))
print(count_max)
break

View File

@ -1,24 +0,0 @@
import io
import sys
sys.stdin = io.StringIO('20200202')
import datetime
s_in = input()
year, month, day = int(s_in[:4]), int(s_in[4:6]), int(s_in[-2:])
now = datetime.date(year, month, day)
one_day = datetime.timedelta(days=1)
reverse = True
while True:
now += one_day
s = str(now).replace('-', '')
if reverse and s[::] == s[::-1]:
print(s)
reverse = False
# ABABBABA
if s[0] == s[2] == s[5] == s[7] and s[1] == s[3] == s[4] == s[6]:
print(s)
break

View File

@ -1,20 +0,0 @@
def bubble_sort(arr):
n = len(arr)
count = 0
for i in range(n):
flag = True
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
flag = False
count += 1
if flag:
break
return count
s = list('jonmlkihgfedcba')
print(bubble_sort(s))

View File

View File

@ -1,15 +0,0 @@
def cal_prime(n):
prime = [1] * (n + 1)
prime[0] = prime[1] = 0
for i in range(2, n + 1):
j = i * i
while j <= n:
prime[j] = 0
j += i
res = []
for idx, num in enumerate(prime):
if num:
res.append(idx)
return res