update project structure
This commit is contained in:
30
luogu_py/P2866.py
Normal file
30
luogu_py/P2866.py
Normal file
@@ -0,0 +1,30 @@
|
||||
N = int(input())
|
||||
length = [int(input()) for i in range(N)]
|
||||
|
||||
# N <= 8 * 10**4, length <= 10**9
|
||||
|
||||
# method 1, has some time exceeded
|
||||
|
||||
"""
|
||||
sum = 0
|
||||
|
||||
for i in range(N):
|
||||
for j in range(i+1,N):
|
||||
if length[i] > length[j]:
|
||||
sum += 1
|
||||
elif length[i] <= length[j]:
|
||||
break
|
||||
"""
|
||||
|
||||
# method 2
|
||||
|
||||
sum = 0
|
||||
i = 0
|
||||
while i < N:
|
||||
for j in range(i + 1, N):
|
||||
if length[i] > length[j]:
|
||||
sum += 1
|
||||
elif length[i] <= length[j]:
|
||||
# maybe something here?
|
||||
break
|
||||
print(sum)
|
||||
71
luogu_py/P5079.py
Normal file
71
luogu_py/P5079.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# input parse
|
||||
rows, columns = input().split(" ")
|
||||
rows = int(rows)
|
||||
columns = int(columns)
|
||||
|
||||
matrix = [["." for _ in range(columns + 2)] for _ in range(rows)]
|
||||
|
||||
for row in range(rows):
|
||||
user_input = input().split(" ")
|
||||
# 确保用户输入的数据长度与列数匹配
|
||||
if len(user_input) != columns:
|
||||
print("Error: Incorrect number of columns entered.")
|
||||
continue
|
||||
# 在第一个点和最后一个点之间插入用户输入
|
||||
matrix[row][1:-1] = user_input
|
||||
|
||||
|
||||
# Subtask 1 (30 points):矩阵中仅有数字1
|
||||
|
||||
# Subtask 2 (30 points):矩阵中不含有数字 1 和 4
|
||||
|
||||
# Subtask 3 (40 points):无特殊性质。
|
||||
|
||||
count1 = 0
|
||||
count2 = 0
|
||||
count3 = 0
|
||||
result = ""
|
||||
number_dict = {
|
||||
"050": "1",
|
||||
"434": "2",
|
||||
"335": "3",
|
||||
"315": "4",
|
||||
"534": "6",
|
||||
"115": "7",
|
||||
"535": "8",
|
||||
"435": "9",
|
||||
"525": "0",
|
||||
}
|
||||
|
||||
first_row = 0
|
||||
for column in range(columns):
|
||||
for row in range(rows):
|
||||
if matrix[row][column] == "#":
|
||||
count1 += 1
|
||||
if matrix[row][column + 1] == "#":
|
||||
count2 += 1
|
||||
if matrix[row][column + 2] == "#":
|
||||
count3 += 1
|
||||
number = str(count1) + str(count2) + str(count3)
|
||||
count1 = 0
|
||||
count2 = 0
|
||||
count3 = 0
|
||||
if number in number_dict.keys():
|
||||
if number == "434":
|
||||
for row in range(rows):
|
||||
try:
|
||||
if matrix[row][column] == "#" and matrix[row + 1][column] == ".":
|
||||
result += "2"
|
||||
break
|
||||
elif matrix[row][column] == "#" and matrix[row + 1][column] == "#":
|
||||
result += "5"
|
||||
break
|
||||
else:
|
||||
pass
|
||||
except IndexError:
|
||||
pass
|
||||
else:
|
||||
result += number_dict[number]
|
||||
|
||||
print(result)
|
||||
|
||||
2
luogu_py/P5705.py
Normal file
2
luogu_py/P5705.py
Normal file
@@ -0,0 +1,2 @@
|
||||
a = input()
|
||||
print(a[::-1])
|
||||
7
luogu_py/p1046.py
Normal file
7
luogu_py/p1046.py
Normal file
@@ -0,0 +1,7 @@
|
||||
a0,a1,a2,a3,a4,a5,a6,a7,a8,a9=map(int,input().split())
|
||||
h=input()
|
||||
num=0
|
||||
for i in [a0,a1,a2,a3,a4,a5,a6,a7,a8,a9]:
|
||||
if ((int(i)) <= (int(h)+30)):
|
||||
num+=1
|
||||
print(num)
|
||||
27
luogu_py/p3717.py
Normal file
27
luogu_py/p3717.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Unfinish
|
||||
from typing import Tuple, List
|
||||
import math
|
||||
|
||||
n, m, r = input().split(" ")
|
||||
locations: List[Tuple[str, str]] = []
|
||||
for i in range(int(m)):
|
||||
location: Tuple[str, str] = tuple(input().split(" "))
|
||||
locations.append(location)
|
||||
|
||||
map = [[0 for _ in range(int(n))] for _ in range(int(n))]
|
||||
count = 0
|
||||
|
||||
for i in range(int(n)):
|
||||
for j in range(int(n)):
|
||||
if map[i][j] == 0:
|
||||
for k in range(int(m)):
|
||||
distance = math.sqrt(
|
||||
(int(locations[k][0]) - i) ** 2 + (int(locations[k][1]) - j) ** 2
|
||||
)
|
||||
if distance <= float(r):
|
||||
map[i][j] = 1
|
||||
count = count + 1
|
||||
break
|
||||
|
||||
print(count)
|
||||
print(map)
|
||||
Reference in New Issue
Block a user