Created
May 13, 2018 04:45
-
-
Save itome/75162f28af4b33552b6f187b846192da to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 097
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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