add 2022蓝桥省赛结束.

This commit is contained in:
Licsber 2022-04-09 12:19:47 +08:00
parent 7b77a1216e
commit 16950b9a5c
15 changed files with 477 additions and 1 deletions

15
.idea/git_toolbox_prj.xml Normal file
View File

@ -0,0 +1,15 @@
<?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,4 +1,22 @@
import io
import sys
sys.stdin = io.StringIO('lanqiao')
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

@ -0,0 +1,10 @@
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

@ -0,0 +1,70 @@
# 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

@ -0,0 +1,69 @@
# 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

@ -0,0 +1,70 @@
# 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

@ -0,0 +1,70 @@
# 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

@ -0,0 +1,13 @@
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

@ -0,0 +1,13 @@
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

@ -0,0 +1,8 @@
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

@ -0,0 +1,33 @@
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

@ -0,0 +1,23 @@
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

@ -0,0 +1,21 @@
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

@ -0,0 +1,23 @@
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

@ -0,0 +1,20 @@
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))