diff --git a/CHANGELOG.md b/CHANGELOG.md index b45b042..3741349 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [v3.14.0](https://github.com/KoyanagiHitoshi/AtCoder-Python-Introduction/releases/tag/v3.14.0) / 2024-02-04 + +* [#35](https://github.com/KoyanagiHitoshi/AtCoder-Python-Introduction/pull/35) add code +* [#35](https://github.com/KoyanagiHitoshi/AtCoder-Python-Introduction/pull/35) update CHANGELOG.md + ## [v3.13.0](https://github.com/KoyanagiHitoshi/AtCoder-Python-Introduction/releases/tag/v3.13.0) / 2024-01-14 * [#34](https://github.com/KoyanagiHitoshi/AtCoder-Python-Introduction/pull/34) add code diff --git a/code/answer_4-2-14.py b/code/answer_4-2-14.py index 16c9f71..573be61 100644 --- a/code/answer_4-2-14.py +++ b/code/answer_4-2-14.py @@ -1,5 +1,12 @@ N = int(input()) -salary = 0 -for i in range(1, N+1): - salary += i*10000*(1/N) -print(salary) +X, Y = 0, 0 +for i in range(N): + x, y = map(int, input().split()) + X += x + Y += y +if X > Y: + print("Takahashi") +elif X < Y: + print("Aoki") +else: + print("Draw") diff --git a/code/answer_4-2-15.py b/code/answer_4-2-15.py index a345403..16c9f71 100644 --- a/code/answer_4-2-15.py +++ b/code/answer_4-2-15.py @@ -1,3 +1,5 @@ N = int(input()) -for i in range(N+1): - print(N-i) +salary = 0 +for i in range(1, N+1): + salary += i*10000*(1/N) +print(salary) diff --git a/code/answer_4-2-16.py b/code/answer_4-2-16.py index 9c00694..a345403 100644 --- a/code/answer_4-2-16.py +++ b/code/answer_4-2-16.py @@ -1,3 +1,3 @@ N = int(input()) -for i in range(N, -1, -1): - print(i) +for i in range(N+1): + print(N-i) diff --git a/code/answer_4-2-17.py b/code/answer_4-2-17.py index 318d4dc..9c00694 100644 --- a/code/answer_4-2-17.py +++ b/code/answer_4-2-17.py @@ -1,4 +1,3 @@ N = int(input()) -print(N) -for i in range(N): - print(1) +for i in range(N, -1, -1): + print(i) diff --git a/code/answer_4-2-18.py b/code/answer_4-2-18.py index 82b14fa..318d4dc 100644 --- a/code/answer_4-2-18.py +++ b/code/answer_4-2-18.py @@ -1,5 +1,4 @@ -N, X = map(int, input().split()) -P = list(map(int, input().split())) +N = int(input()) +print(N) for i in range(N): - if P[i] == X: - print(i+1) + print(1) diff --git a/code/answer_4-2-19.py b/code/answer_4-2-19.py index 30cbffb..82b14fa 100644 --- a/code/answer_4-2-19.py +++ b/code/answer_4-2-19.py @@ -1,5 +1,5 @@ -N, A, B = map(int, input().split()) -C = list(map(int, input().split())) +N, X = map(int, input().split()) +P = list(map(int, input().split())) for i in range(N): - if A+B == C[i]: + if P[i] == X: print(i+1) diff --git a/code/answer_4-2-20.py b/code/answer_4-2-20.py index 98a96c5..30cbffb 100644 --- a/code/answer_4-2-20.py +++ b/code/answer_4-2-20.py @@ -1,7 +1,5 @@ -N, M, P = map(int, input().split()) -count = 0 +N, A, B = map(int, input().split()) +C = list(map(int, input().split())) for i in range(N): - if M <= N: - count += 1 - M += P -print(count) + if A+B == C[i]: + print(i+1) diff --git a/code/answer_4-2-21.py b/code/answer_4-2-21.py index 58fff57..98a96c5 100644 --- a/code/answer_4-2-21.py +++ b/code/answer_4-2-21.py @@ -1,6 +1,7 @@ -N, H, X = map(int, input().split()) -P = list(map(int, input().split())) +N, M, P = map(int, input().split()) +count = 0 for i in range(N): - if H+P[i] >= X: - print(i+1) - break + if M <= N: + count += 1 + M += P +print(count) diff --git a/code/answer_4-2-22.py b/code/answer_4-2-22.py index 17aa2d5..58fff57 100644 --- a/code/answer_4-2-22.py +++ b/code/answer_4-2-22.py @@ -1,11 +1,6 @@ -N, S, T = map(int, input().split()) -W = int(input()) -day = 0 -if S <= W <= T: - day += 1 -for i in range(N-1): - A = int(input()) - W += A - if S <= W <= T: - day += 1 -print(day) +N, H, X = map(int, input().split()) +P = list(map(int, input().split())) +for i in range(N): + if H+P[i] >= X: + print(i+1) + break diff --git a/code/answer_4-2-23.py b/code/answer_4-2-23.py index 23f7cb9..17aa2d5 100644 --- a/code/answer_4-2-23.py +++ b/code/answer_4-2-23.py @@ -1,14 +1,11 @@ -A, B, C, D, E, F, X = map(int, input().split()) -takahashi = 0 -aoki = 0 -for i in range(X): - if i % (A+C) < A: - takahashi += B - if i % (D+F) < D: - aoki += E -if takahashi > aoki: - print("Takahashi") -elif takahashi < aoki: - print("Aoki") -else: - print("Draw") +N, S, T = map(int, input().split()) +W = int(input()) +day = 0 +if S <= W <= T: + day += 1 +for i in range(N-1): + A = int(input()) + W += A + if S <= W <= T: + day += 1 +print(day) diff --git a/code/answer_4-2-24.py b/code/answer_4-2-24.py index 2481291..23f7cb9 100644 --- a/code/answer_4-2-24.py +++ b/code/answer_4-2-24.py @@ -1,7 +1,14 @@ -A, B, C = map(int, input().split()) -for i in range(A, B+1): - if i % C == 0: - print(i) - break +A, B, C, D, E, F, X = map(int, input().split()) +takahashi = 0 +aoki = 0 +for i in range(X): + if i % (A+C) < A: + takahashi += B + if i % (D+F) < D: + aoki += E +if takahashi > aoki: + print("Takahashi") +elif takahashi < aoki: + print("Aoki") else: - print(-1) + print("Draw") diff --git a/code/answer_4-2-25.py b/code/answer_4-2-25.py index 721e060..2481291 100644 --- a/code/answer_4-2-25.py +++ b/code/answer_4-2-25.py @@ -1,8 +1,7 @@ -K = int(input()) -A, B = map(int, input().split()) +A, B, C = map(int, input().split()) for i in range(A, B+1): - if i % K == 0: - print("OK") + if i % C == 0: + print(i) break else: - print("NG") + print(-1) diff --git a/code/answer_4-2-26.py b/code/answer_4-2-26.py index 5a00165..721e060 100644 --- a/code/answer_4-2-26.py +++ b/code/answer_4-2-26.py @@ -1,9 +1,8 @@ -N = int(input()) -W = input().split() -S = {"and", "not", "that", "the", "you"} -for w in W: - if w in S: - print("Yes") +K = int(input()) +A, B = map(int, input().split()) +for i in range(A, B+1): + if i % K == 0: + print("OK") break else: - print("No") + print("NG") diff --git a/code/answer_4-2-27.py b/code/answer_4-2-27.py index 5a8fd77..5a00165 100644 --- a/code/answer_4-2-27.py +++ b/code/answer_4-2-27.py @@ -1,7 +1,9 @@ -N = input() -for i in range(len(N)-1): - if N[i] <= N[i+1]: - print("No") +N = int(input()) +W = input().split() +S = {"and", "not", "that", "the", "you"} +for w in W: + if w in S: + print("Yes") break else: - print("Yes") + print("No") diff --git a/code/answer_4-2-28.py b/code/answer_4-2-28.py index 01f8c28..5a8fd77 100644 --- a/code/answer_4-2-28.py +++ b/code/answer_4-2-28.py @@ -1,7 +1,6 @@ -N = int(input()) -S = input() -for i in range(N-1): - if S[i] == S[i+1]: +N = input() +for i in range(len(N)-1): + if N[i] <= N[i+1]: print("No") break else: diff --git a/code/answer_4-2-29.py b/code/answer_4-2-29.py index 78d9ce1..01f8c28 100644 --- a/code/answer_4-2-29.py +++ b/code/answer_4-2-29.py @@ -1,9 +1,8 @@ N = int(input()) S = input() for i in range(N-1): - if S[i] != S[i+1]: - continue - print("No") - break + if S[i] == S[i+1]: + print("No") + break else: print("Yes") diff --git a/code/answer_4-2-30.py b/code/answer_4-2-30.py index 6080dd7..78d9ce1 100644 --- a/code/answer_4-2-30.py +++ b/code/answer_4-2-30.py @@ -1,7 +1,9 @@ +N = int(input()) S = input() -for i in range(1, 16, 2): - if S[i] != "0": - print("No") - break +for i in range(N-1): + if S[i] != S[i+1]: + continue + print("No") + break else: print("Yes") diff --git a/code/answer_4-2-31.py b/code/answer_4-2-31.py index 114d8cb..6080dd7 100644 --- a/code/answer_4-2-31.py +++ b/code/answer_4-2-31.py @@ -1,8 +1,6 @@ S = input() for i in range(1, 16, 2): - if S[i] == "0": - continue - else: + if S[i] != "0": print("No") break else: diff --git a/code/answer_4-2-32.py b/code/answer_4-2-32.py index d42f357..114d8cb 100644 --- a/code/answer_4-2-32.py +++ b/code/answer_4-2-32.py @@ -1,4 +1,9 @@ -N = int(input()) -while N >= 0: - print(N) - N -= 1 +S = input() +for i in range(1, 16, 2): + if S[i] == "0": + continue + else: + print("No") + break +else: + print("Yes") diff --git a/code/answer_4-2-33.py b/code/answer_4-2-33.py index 705d8a2..d42f357 100644 --- a/code/answer_4-2-33.py +++ b/code/answer_4-2-33.py @@ -1,4 +1,4 @@ -a, b, n = [int(input()) for i in range(3)] -while n % a != 0 or n % b != 0: - n += 1 -print(n) +N = int(input()) +while N >= 0: + print(N) + N -= 1 diff --git a/code/answer_4-2-34.py b/code/answer_4-2-34.py index dac5862..705d8a2 100644 --- a/code/answer_4-2-34.py +++ b/code/answer_4-2-34.py @@ -1,4 +1,4 @@ a, b, n = [int(input()) for i in range(3)] -while not (n % a == 0 and n % b == 0): +while n % a != 0 or n % b != 0: n += 1 print(n) diff --git a/code/answer_4-2-35.py b/code/answer_4-2-35.py index 36bdac2..dac5862 100644 --- a/code/answer_4-2-35.py +++ b/code/answer_4-2-35.py @@ -1,6 +1,4 @@ -N, M, P = map(int, input().split()) -count = 0 -while M <= N: - count += 1 - M += P -print(count) +a, b, n = [int(input()) for i in range(3)] +while not (n % a == 0 and n % b == 0): + n += 1 +print(n) diff --git a/code/answer_4-2-36.py b/code/answer_4-2-36.py new file mode 100644 index 0000000..36bdac2 --- /dev/null +++ b/code/answer_4-2-36.py @@ -0,0 +1,6 @@ +N, M, P = map(int, input().split()) +count = 0 +while M <= N: + count += 1 + M += P +print(count) diff --git a/code/answer_5-3-68.py b/code/answer_5-3-68.py index 11aaf97..ab5b106 100644 --- a/code/answer_5-3-68.py +++ b/code/answer_5-3-68.py @@ -1,2 +1,3 @@ S = input() -print((S*6)[:6]) +dot = S.rfind(".") +print(S[dot+1:]) diff --git a/code/answer_5-3-69.py b/code/answer_5-3-69.py index caa10b1..11aaf97 100644 --- a/code/answer_5-3-69.py +++ b/code/answer_5-3-69.py @@ -1,6 +1,2 @@ S = input() -T = input() -if S == T[:-1]: - print("Yes") -else: - print("No") +print((S*6)[:6]) diff --git a/code/answer_5-3-70.py b/code/answer_5-3-70.py index 1f576aa..caa10b1 100644 --- a/code/answer_5-3-70.py +++ b/code/answer_5-3-70.py @@ -1,5 +1,6 @@ S = input() -if S[-2:] == "er": - print("er") +T = input() +if S == T[:-1]: + print("Yes") else: - print("ist") + print("No") diff --git a/code/answer_5-3-71.py b/code/answer_5-3-71.py index 9a3b5d8..1f576aa 100644 --- a/code/answer_5-3-71.py +++ b/code/answer_5-3-71.py @@ -1,2 +1,5 @@ -s = input() -print(s[::2]) +S = input() +if S[-2:] == "er": + print("er") +else: + print("ist") diff --git a/code/answer_5-3-72.py b/code/answer_5-3-72.py index 8902cef..9a3b5d8 100644 --- a/code/answer_5-3-72.py +++ b/code/answer_5-3-72.py @@ -1,5 +1,2 @@ -N = input() -if N == N[::-1]: - print("Yes") -else: - print("No") +s = input() +print(s[::2]) diff --git a/code/answer_5-3-73.py b/code/answer_5-3-73.py index 1e90a1d..8902cef 100644 --- a/code/answer_5-3-73.py +++ b/code/answer_5-3-73.py @@ -1,6 +1,5 @@ -c1 = input() -c2 = input() -if c1 == c2[::-1]: - print("YES") +N = input() +if N == N[::-1]: + print("Yes") else: - print("NO") + print("No") diff --git a/code/answer_5-3-74.py b/code/answer_5-3-74.py index 015f51d..1e90a1d 100644 --- a/code/answer_5-3-74.py +++ b/code/answer_5-3-74.py @@ -1,2 +1,6 @@ -s = input() -print(s.replace("0", "x").replace("1", "0").replace("x", "1")) +c1 = input() +c2 = input() +if c1 == c2[::-1]: + print("YES") +else: + print("NO") diff --git a/code/answer_5-3-75.py b/code/answer_5-3-75.py index 01bb060..da41bc5 100644 --- a/code/answer_5-3-75.py +++ b/code/answer_5-3-75.py @@ -1,2 +1,8 @@ -n = input() -print(n.replace("1", "x").replace("9", "1").replace("x", "9")) +S = input() +ans = "" +for s in S[::-1]: + if s == ".": + break + else: + ans += s +print(ans[::-1]) diff --git a/code/answer_5-3-76.py b/code/answer_5-3-76.py index 4fc40b0..015f51d 100644 --- a/code/answer_5-3-76.py +++ b/code/answer_5-3-76.py @@ -1,6 +1,2 @@ -S = input() -print(S.replace("a", "") - .replace("e", "") - .replace("i", "") - .replace("o", "") - .replace("u", "")) +s = input() +print(s.replace("0", "x").replace("1", "0").replace("x", "1")) diff --git a/code/answer_5-3-77.py b/code/answer_5-3-77.py index d87bdca..01bb060 100644 --- a/code/answer_5-3-77.py +++ b/code/answer_5-3-77.py @@ -1,6 +1,2 @@ -N = int(input()) -S = input() -if S.replace(".", "") == "|*|": - print("in") -else: - print("out") +n = input() +print(n.replace("1", "x").replace("9", "1").replace("x", "9")) diff --git a/code/answer_5-3-78.py b/code/answer_5-3-78.py index 613fd4c..4fc40b0 100644 --- a/code/answer_5-3-78.py +++ b/code/answer_5-3-78.py @@ -1,7 +1,6 @@ -N = int(input()) -S = input().replace("1", "l").replace("0", "o") -T = input().replace("1", "l").replace("0", "o") -if S == T: - print("Yes") -else: - print("No") +S = input() +print(S.replace("a", "") + .replace("e", "") + .replace("i", "") + .replace("o", "") + .replace("u", "")) diff --git a/code/answer_5-3-79.py b/code/answer_5-3-79.py index b7e865d..d87bdca 100644 --- a/code/answer_5-3-79.py +++ b/code/answer_5-3-79.py @@ -1,3 +1,6 @@ +N = int(input()) S = input() -T = S.upper() -print(T) +if S.replace(".", "") == "|*|": + print("in") +else: + print("out") diff --git a/code/answer_5-3-80.py b/code/answer_5-3-80.py index fb3ed45..613fd4c 100644 --- a/code/answer_5-3-80.py +++ b/code/answer_5-3-80.py @@ -1,2 +1,7 @@ -s1, s2, s3 = input().split() -print((s1[0]+s2[0]+s3[0]).upper()) +N = int(input()) +S = input().replace("1", "l").replace("0", "o") +T = input().replace("1", "l").replace("0", "o") +if S == T: + print("Yes") +else: + print("No") diff --git a/code/answer_5-3-81.py b/code/answer_5-3-81.py index 99f2932..b7e865d 100644 --- a/code/answer_5-3-81.py +++ b/code/answer_5-3-81.py @@ -1,3 +1,3 @@ -S = input().split() -for s in S: - print(s[0].upper(), end="") +S = input() +T = S.upper() +print(T) diff --git a/code/answer_5-3-82.py b/code/answer_5-3-82.py index 55cc041..fb3ed45 100644 --- a/code/answer_5-3-82.py +++ b/code/answer_5-3-82.py @@ -1,3 +1,2 @@ -N, K = map(int, input().split()) -S = input() -print(S[:K-1]+S[K-1:K].lower()+S[K:]) +s1, s2, s3 = input().split() +print((s1[0]+s2[0]+s3[0]).upper()) diff --git a/code/answer_5-3-83.py b/code/answer_5-3-83.py index 746009f..99f2932 100644 --- a/code/answer_5-3-83.py +++ b/code/answer_5-3-83.py @@ -1,8 +1,3 @@ -S = input() -idx = 1 +S = input().split() for s in S: - if s.isupper(): - break - else: - idx += 1 -print(idx) + print(s[0].upper(), end="") diff --git a/code/answer_5-3-84.py b/code/answer_5-3-84.py index 431582a..55cc041 100644 --- a/code/answer_5-3-84.py +++ b/code/answer_5-3-84.py @@ -1,2 +1,3 @@ -N = input() -print(N.zfill(4)) +N, K = map(int, input().split()) +S = input() +print(S[:K-1]+S[K-1:K].lower()+S[K:]) diff --git a/code/answer_5-3-85.py b/code/answer_5-3-85.py index 77b0bc1..1b713e5 100644 --- a/code/answer_5-3-85.py +++ b/code/answer_5-3-85.py @@ -1,5 +1,5 @@ -N = int(input()) -if N < 42: - print("AGC"+str(N).zfill(3)) +S = input() +if S == S[0].upper()+S[1:].lower(): + print("Yes") else: - print("AGC"+str(N+1).zfill(3)) + print("No") diff --git a/code/answer_5-3-86.py b/code/answer_5-3-86.py index 5a77e12..746009f 100644 --- a/code/answer_5-3-86.py +++ b/code/answer_5-3-86.py @@ -1,2 +1,8 @@ -N = int(input()) -print(f"{N:04}") +S = input() +idx = 1 +for s in S: + if s.isupper(): + break + else: + idx += 1 +print(idx) diff --git a/code/answer_5-3-87.py b/code/answer_5-3-87.py index fa2e473..431582a 100644 --- a/code/answer_5-3-87.py +++ b/code/answer_5-3-87.py @@ -1,5 +1,2 @@ -N = int(input()) -if N < 42: - print(f"AGC{N:03}") -else: - print(f"AGC{N+1:03}") +N = input() +print(N.zfill(4)) diff --git a/code/answer_5-3-88.py b/code/answer_5-3-88.py index 1a03e06..77b0bc1 100644 --- a/code/answer_5-3-88.py +++ b/code/answer_5-3-88.py @@ -1,2 +1,5 @@ -A, B = map(int, input().split()) -print(f"{B/A:.3f}") +N = int(input()) +if N < 42: + print("AGC"+str(N).zfill(3)) +else: + print("AGC"+str(N+1).zfill(3)) diff --git a/code/answer_5-3-89.py b/code/answer_5-3-89.py index 1f45e84..5a77e12 100644 --- a/code/answer_5-3-89.py +++ b/code/answer_5-3-89.py @@ -1,2 +1,2 @@ N = int(input()) -print(f"{N:02X}") +print(f"{N:04}") diff --git a/code/answer_5-3-90.py b/code/answer_5-3-90.py new file mode 100644 index 0000000..fa2e473 --- /dev/null +++ b/code/answer_5-3-90.py @@ -0,0 +1,5 @@ +N = int(input()) +if N < 42: + print(f"AGC{N:03}") +else: + print(f"AGC{N+1:03}") diff --git a/code/answer_5-3-91.py b/code/answer_5-3-91.py new file mode 100644 index 0000000..1a03e06 --- /dev/null +++ b/code/answer_5-3-91.py @@ -0,0 +1,2 @@ +A, B = map(int, input().split()) +print(f"{B/A:.3f}") diff --git a/code/answer_5-3-92.py b/code/answer_5-3-92.py new file mode 100644 index 0000000..1f45e84 --- /dev/null +++ b/code/answer_5-3-92.py @@ -0,0 +1,2 @@ +N = int(input()) +print(f"{N:02X}") diff --git a/code/answer_5-4-10.py b/code/answer_5-4-10.py index b5c4522..90ab7dd 100644 --- a/code/answer_5-4-10.py +++ b/code/answer_5-4-10.py @@ -1,8 +1,4 @@ -N, D = map(int, input().split()) -T = list(map(int, input().split())) -for i in range(N-1): - if T[i+1]-T[i] <= D: - print(T[i+1]) - break -else: - print(-1) +N = int(input()) +S = [input() for i in range(N)] +for i in range(N-1, -1, -1): + print(S[i]) diff --git a/code/answer_5-4-11.py b/code/answer_5-4-11.py index 78f5df3..b5c4522 100644 --- a/code/answer_5-4-11.py +++ b/code/answer_5-4-11.py @@ -1,13 +1,8 @@ -S = list(map(int, input().split())) -flag = True -for i in range(7): - if S[i] <= S[i+1]: - continue - else: - flag = False -for s in S: - if 100 <= s <= 675 and s % 25 == 0: - continue - else: - flag = False -print("Yes" if flag else "No") +N, D = map(int, input().split()) +T = list(map(int, input().split())) +for i in range(N-1): + if T[i+1]-T[i] <= D: + print(T[i+1]) + break +else: + print(-1) diff --git a/code/answer_5-4-12.py b/code/answer_5-4-12.py index a5b4f9e..78f5df3 100644 --- a/code/answer_5-4-12.py +++ b/code/answer_5-4-12.py @@ -1,2 +1,13 @@ -X = input() -print(["A", "B", "C", "D", "E"].index(X)+1) +S = list(map(int, input().split())) +flag = True +for i in range(7): + if S[i] <= S[i+1]: + continue + else: + flag = False +for s in S: + if 100 <= s <= 675 and s % 25 == 0: + continue + else: + flag = False +print("Yes" if flag else "No") diff --git a/code/answer_5-4-13.py b/code/answer_5-4-13.py index 868fda0..a5b4f9e 100644 --- a/code/answer_5-4-13.py +++ b/code/answer_5-4-13.py @@ -1,2 +1,2 @@ X = input() -print(["0", "A", "B", "C", "D", "E"].index(X)) +print(["A", "B", "C", "D", "E"].index(X)+1) diff --git a/code/answer_5-4-14.py b/code/answer_5-4-14.py index d957c00..868fda0 100644 --- a/code/answer_5-4-14.py +++ b/code/answer_5-4-14.py @@ -1,2 +1,2 @@ -x = list(map(int, input().split())) -print(x.index(0)+1) +X = input() +print(["0", "A", "B", "C", "D", "E"].index(X)) diff --git a/code/answer_5-4-15.py b/code/answer_5-4-15.py index f531976..d957c00 100644 --- a/code/answer_5-4-15.py +++ b/code/answer_5-4-15.py @@ -1,2 +1,2 @@ -x = input().split() -print(x.index("0")+1) +x = list(map(int, input().split())) +print(x.index(0)+1) diff --git a/code/answer_5-4-16.py b/code/answer_5-4-16.py index 5cc82ff..f531976 100644 --- a/code/answer_5-4-16.py +++ b/code/answer_5-4-16.py @@ -1,3 +1,2 @@ -N, X = map(int, input().split()) -P = list(map(int, input().split())) -print(P.index(X)+1) +x = input().split() +print(x.index("0")+1) diff --git a/code/answer_5-4-17.py b/code/answer_5-4-17.py index ca68bc5..5cc82ff 100644 --- a/code/answer_5-4-17.py +++ b/code/answer_5-4-17.py @@ -1,3 +1,3 @@ -N, X = input().split() -P = input().split() +N, X = map(int, input().split()) +P = list(map(int, input().split())) print(P.index(X)+1) diff --git a/code/answer_5-4-18.py b/code/answer_5-4-18.py index 739168b..ca68bc5 100644 --- a/code/answer_5-4-18.py +++ b/code/answer_5-4-18.py @@ -1,3 +1,3 @@ -N, A, B = map(int, input().split()) -C = list(map(int, input().split())) -print(C.index(A+B)+1) +N, X = input().split() +P = input().split() +print(P.index(X)+1) diff --git a/code/answer_5-4-19.py b/code/answer_5-4-19.py index 1738116..739168b 100644 --- a/code/answer_5-4-19.py +++ b/code/answer_5-4-19.py @@ -1,3 +1,3 @@ -S = input() -week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"] -print(7-week.index(S)) +N, A, B = map(int, input().split()) +C = list(map(int, input().split())) +print(C.index(A+B)+1) diff --git a/code/answer_5-4-20.py b/code/answer_5-4-20.py index c2a5aab..1738116 100644 --- a/code/answer_5-4-20.py +++ b/code/answer_5-4-20.py @@ -1,3 +1,3 @@ S = input() -week = ["0", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"] -print(week.index(S)) +week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"] +print(7-week.index(S)) diff --git a/code/answer_5-4-21.py b/code/answer_5-4-21.py index 701f9ab..c2a5aab 100644 --- a/code/answer_5-4-21.py +++ b/code/answer_5-4-21.py @@ -1,3 +1,3 @@ S = input() -week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] -print(5-week.index(S)) +week = ["0", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"] +print(week.index(S)) diff --git a/code/answer_5-4-22.py b/code/answer_5-4-22.py index 49c9076..701f9ab 100644 --- a/code/answer_5-4-22.py +++ b/code/answer_5-4-22.py @@ -1,3 +1,3 @@ S = input() -week = ["0", "Friday", "Thursday", "Wednesday", "Tuesday", "Monday"] -print(week.index(S)) +week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] +print(5-week.index(S)) diff --git a/code/answer_5-4-23.py b/code/answer_5-4-23.py index 2fd7184..49c9076 100644 --- a/code/answer_5-4-23.py +++ b/code/answer_5-4-23.py @@ -1,3 +1,3 @@ S = input() -weather = ["Sunny", "Cloudy", "Rainy", "Sunny"] -print(weather[(weather.index(S)+1)]) +week = ["0", "Friday", "Thursday", "Wednesday", "Tuesday", "Monday"] +print(week.index(S)) diff --git a/code/answer_5-4-24.py b/code/answer_5-4-24.py index 60cb8de..2fd7184 100644 --- a/code/answer_5-4-24.py +++ b/code/answer_5-4-24.py @@ -1,3 +1,3 @@ S = input() -weather = ["Sunny", "Cloudy", "Rainy"] -print(weather[(weather.index(S)+1) % 3]) +weather = ["Sunny", "Cloudy", "Rainy", "Sunny"] +print(weather[(weather.index(S)+1)]) diff --git a/code/answer_5-4-25.py b/code/answer_5-4-25.py index a893d9f..60cb8de 100644 --- a/code/answer_5-4-25.py +++ b/code/answer_5-4-25.py @@ -1,7 +1,3 @@ -N = int(input()) -H = list(map(int, input().split())) -bridge = 0 -for h in H: - if h > bridge: - bridge = h -print(H.index(bridge)+1) +S = input() +weather = ["Sunny", "Cloudy", "Rainy"] +print(weather[(weather.index(S)+1) % 3]) diff --git a/code/answer_5-4-26.py b/code/answer_5-4-26.py index 325e390..a893d9f 100644 --- a/code/answer_5-4-26.py +++ b/code/answer_5-4-26.py @@ -1,5 +1,7 @@ -ABC = list(map(int, input().split())) -if ABC.count(5) == 2 and ABC.count(7) == 1: - print("YES") -else: - print("NO") +N = int(input()) +H = list(map(int, input().split())) +bridge = 0 +for h in H: + if h > bridge: + bridge = h +print(H.index(bridge)+1) diff --git a/code/answer_5-4-27.py b/code/answer_5-4-27.py index 2ee283d..325e390 100644 --- a/code/answer_5-4-27.py +++ b/code/answer_5-4-27.py @@ -1,5 +1,5 @@ -ABC = input().split() -if ABC.count("5") == 2 and ABC.count("7") == 1: +ABC = list(map(int, input().split())) +if ABC.count(5) == 2 and ABC.count(7) == 1: print("YES") else: print("NO") diff --git a/code/answer_5-4-28.py b/code/answer_5-4-28.py index f347bcd..2ee283d 100644 --- a/code/answer_5-4-28.py +++ b/code/answer_5-4-28.py @@ -1,6 +1,5 @@ -N = int(input()) -S = [input() for i in range(N)] -if S.count("For") > N/2: - print("Yes") +ABC = input().split() +if ABC.count("5") == 2 and ABC.count("7") == 1: + print("YES") else: - print("No") + print("NO") diff --git a/code/answer_5-4-29.py b/code/answer_5-4-29.py index 09b0194..f347bcd 100644 --- a/code/answer_5-4-29.py +++ b/code/answer_5-4-29.py @@ -1,6 +1,6 @@ -N, K = map(int, input().split()) -A = list(map(int, input().split())) -for i in range(K): - A.pop(0) - A.append(0) -print(*A) +N = int(input()) +S = [input() for i in range(N)] +if S.count("For") > N/2: + print("Yes") +else: + print("No") diff --git a/code/answer_5-4-30.py b/code/answer_5-4-30.py index c4ec4bb..09b0194 100644 --- a/code/answer_5-4-30.py +++ b/code/answer_5-4-30.py @@ -1,4 +1,6 @@ -N, P, Q, R, S = map(int, input().split()) +N, K = map(int, input().split()) A = list(map(int, input().split())) -A[P-1:Q], A[R-1:S] = A[R-1:S], A[P-1:Q] +for i in range(K): + A.pop(0) + A.append(0) print(*A) diff --git a/code/answer_5-4-31.py b/code/answer_5-4-31.py index b9c020e..c4ec4bb 100644 --- a/code/answer_5-4-31.py +++ b/code/answer_5-4-31.py @@ -1,4 +1,4 @@ N, P, Q, R, S = map(int, input().split()) -A = input().split() +A = list(map(int, input().split())) A[P-1:Q], A[R-1:S] = A[R-1:S], A[P-1:Q] print(*A) diff --git a/code/answer_5-4-32.py b/code/answer_5-4-32.py index c3d6718..b9c020e 100644 --- a/code/answer_5-4-32.py +++ b/code/answer_5-4-32.py @@ -1,4 +1,4 @@ -N = int(input()) -S = [input() for i in range(N)] -for s in S[::-1]: - print(s) +N, P, Q, R, S = map(int, input().split()) +A = input().split() +A[P-1:Q], A[R-1:S] = A[R-1:S], A[P-1:Q] +print(*A) diff --git a/code/answer_5-4-33.py b/code/answer_5-4-33.py index 835330f..c3d6718 100644 --- a/code/answer_5-4-33.py +++ b/code/answer_5-4-33.py @@ -1,9 +1,4 @@ N = int(input()) -S = [] -A = [] -for i in range(N): - s, a = input().split() - S.append(s) - A.append(int(a)) -idx = A.index(min(A)) -print(*S[idx:]+S[:idx], sep="\n") +S = [input() for i in range(N)] +for s in S[::-1]: + print(s) diff --git a/code/answer_5-4-34.py b/code/answer_5-4-34.py new file mode 100644 index 0000000..835330f --- /dev/null +++ b/code/answer_5-4-34.py @@ -0,0 +1,9 @@ +N = int(input()) +S = [] +A = [] +for i in range(N): + s, a = input().split() + S.append(s) + A.append(int(a)) +idx = A.index(min(A)) +print(*S[idx:]+S[:idx], sep="\n") diff --git a/code/answer_5-4-4.py b/code/answer_5-4-4.py index 0d9a3cd..8b60649 100644 --- a/code/answer_5-4-4.py +++ b/code/answer_5-4-4.py @@ -1,6 +1,2 @@ -N = int(input()) -A = list(map(int, input().split())) -total = 0 -for i in range(N): - total += A[i] -print(total) +S = input() +print(S.split(".")[-1]) diff --git a/code/answer_5-4-5.py b/code/answer_5-4-5.py index f368e87..0d9a3cd 100644 --- a/code/answer_5-4-5.py +++ b/code/answer_5-4-5.py @@ -1,7 +1,6 @@ -N, M = map(int, input().split()) +N = int(input()) A = list(map(int, input().split())) -B = list(map(int, input().split())) total = 0 -for b in B: - total += A[b-1] +for i in range(N): + total += A[i] print(total) diff --git a/code/answer_5-4-6.py b/code/answer_5-4-6.py index 573fc24..f368e87 100644 --- a/code/answer_5-4-6.py +++ b/code/answer_5-4-6.py @@ -2,6 +2,6 @@ A = list(map(int, input().split())) B = list(map(int, input().split())) total = 0 -for i in range(M): - total += A[B[i]-1] +for b in B: + total += A[b-1] print(total) diff --git a/code/answer_5-4-7.py b/code/answer_5-4-7.py index 24f4f08..573fc24 100644 --- a/code/answer_5-4-7.py +++ b/code/answer_5-4-7.py @@ -1,3 +1,7 @@ -N = input() -book = ["pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"] -print(book[int(N[-1])]) +N, M = map(int, input().split()) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +total = 0 +for i in range(M): + total += A[B[i]-1] +print(total) diff --git a/code/answer_5-4-8.py b/code/answer_5-4-8.py index 4bcf104..24f4f08 100644 --- a/code/answer_5-4-8.py +++ b/code/answer_5-4-8.py @@ -1,4 +1,3 @@ -N = int(input()) -S = [input() for i in range(N)] -for i in range(N): - print(S[N-i-1]) +N = input() +book = ["pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"] +print(book[int(N[-1])]) diff --git a/code/answer_5-4-9.py b/code/answer_5-4-9.py index 90ab7dd..4bcf104 100644 --- a/code/answer_5-4-9.py +++ b/code/answer_5-4-9.py @@ -1,4 +1,4 @@ N = int(input()) S = [input() for i in range(N)] -for i in range(N-1, -1, -1): - print(S[i]) +for i in range(N): + print(S[N-i-1])