Skip to content

Instantly share code, notes, and snippets.

@itome
Created May 13, 2018 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itome/75162f28af4b33552b6f187b846192da to your computer and use it in GitHub Desktop.
Save itome/75162f28af4b33552b6f187b846192da to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 097
a, b, c, d = map(int, input().split())
if abs(a - c) <= d or abs(a - b) <= d and abs(b - c) <= d:
print("Yes")
else:
print("No")
X = int(input())
perfectNumbers = set([1])
for i in range(2, 33):
j = 2
while True:
perfectNumbers.add(i**j)
j += 1
if (i**j > 1000):
break
ans = 0
for i in sorted(perfectNumbers):
if i > X:
break
ans = i
print(ans)
import re
s = input()
K = int(input())
chars = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
]
current = ""
for i in range(K):
if current == "":
current = min(s)
continue
startIndexes = [m.start() for m in re.finditer(current, s)]
candidates = [s[index:index + len(current) + 1] for index in startIndexes]
for candidate in candidates:
if candidate == current:
candidates.remove(candidate)
if not candidates:
current = min(s.replace(current[0], ""))
else:
current = min(candidates)
print(current)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment