Compare commits
5 Commits
09cc6efe46
...
c5728fa19e
| Author | SHA1 | Date | |
|---|---|---|---|
| c5728fa19e | |||
| 61b575d34f | |||
| 30941abe2d | |||
| 3963a3498a | |||
| adb3cc79d4 |
30
1dfroggereasy.py
Normal file
30
1dfroggereasy.py
Normal file
@@ -0,0 +1,30 @@
|
||||
n, s, m = map(int, input().split())
|
||||
s -= 1
|
||||
board = list(map(int, input().split()))
|
||||
shadow_board = [0] * n
|
||||
|
||||
|
||||
def print_ending(ending, hops):
|
||||
print(ending)
|
||||
print(hops)
|
||||
exit()
|
||||
|
||||
|
||||
hops = 0
|
||||
while True:
|
||||
if shadow_board[s] == 1:
|
||||
print_ending("cycle", hops)
|
||||
|
||||
shadow_board[s] = 1
|
||||
|
||||
if board[s] == m:
|
||||
print_ending("magic", hops)
|
||||
|
||||
if s + board[s] < 0:
|
||||
print_ending("left", hops + 1)
|
||||
|
||||
if n <= s + board[s]:
|
||||
print_ending("right", hops + 1)
|
||||
|
||||
s += board[s]
|
||||
hops += 1
|
||||
28
heirsdilemma.py
Normal file
28
heirsdilemma.py
Normal file
@@ -0,0 +1,28 @@
|
||||
def div_by_all(nr: int) -> bool:
|
||||
digits = nr
|
||||
for i in range(1, 7):
|
||||
digit = digits % (10**i)
|
||||
if nr % (digit // (10 ** (i - 1))) != 0:
|
||||
return False
|
||||
digits -= digit
|
||||
return True
|
||||
|
||||
|
||||
low, high = map(int, input().split())
|
||||
|
||||
if low % 2 == 1:
|
||||
low += 1
|
||||
|
||||
total = 0
|
||||
|
||||
for i in range(low, high + 1, 2):
|
||||
u = set(str(i))
|
||||
if len(u) != len(str(i)):
|
||||
continue
|
||||
if "0" in u:
|
||||
continue
|
||||
|
||||
if div_by_all(i):
|
||||
total += 1
|
||||
|
||||
print(total)
|
||||
6
helpaphd.py
Normal file
6
helpaphd.py
Normal file
@@ -0,0 +1,6 @@
|
||||
for _ in range(int(input())):
|
||||
testcase = input()
|
||||
if testcase == "P=NP":
|
||||
print("skipped")
|
||||
else:
|
||||
print(sum(map(int, testcase.split("+"))))
|
||||
5
herman.py
Normal file
5
herman.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import math
|
||||
|
||||
r = int(input())
|
||||
print(r**2 * math.pi)
|
||||
print(r**2 * 2)
|
||||
32
hittingtargets.py
Normal file
32
hittingtargets.py
Normal file
@@ -0,0 +1,32 @@
|
||||
def isInsideCircle(cx, cy, r, x, y):
|
||||
dist = (x - cx) ** 2 + (y - cy) ** 2
|
||||
return dist <= r**2
|
||||
|
||||
|
||||
def isInsideRectangle(rx1, ry1, rx2, ry2, x, y):
|
||||
return (rx1 <= x <= rx2) and (ry1 <= y <= ry2)
|
||||
|
||||
|
||||
targets = []
|
||||
for _ in range(int(input())):
|
||||
t = input().split()
|
||||
if t[0] == "rectangle":
|
||||
targets.append(["R", int(t[1]), int(t[2]), int(t[3]), int(t[4])])
|
||||
else:
|
||||
targets.append(["C", int(t[1]), int(t[2]), int(t[3])])
|
||||
|
||||
for _ in range(int(input())):
|
||||
x, y = map(int, input().split())
|
||||
hits = 0
|
||||
|
||||
for target in targets:
|
||||
if target[0] == "R":
|
||||
hits += (
|
||||
1
|
||||
if isInsideRectangle(target[1], target[2], target[3], target[4], x, y)
|
||||
else 0
|
||||
)
|
||||
else:
|
||||
hits += 1 if isInsideCircle(target[1], target[2], target[3], x, y) else 0
|
||||
|
||||
print(hits)
|
||||
Reference in New Issue
Block a user