Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?



Python で「AtCoder に登録したら次にやること ~ これだけ解けば十分闘える!過去問精選 10 問 ~」を解きました。


解いたコードは AtCoder の下記言語で AC になることを確認しました。

Python 3.8.2

第1問 ABC086A - Product

a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")


第2問 ABC081A - Placing Marbles

s = input()


第3問 ABC081B - Shift only

N = int(input())
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1


第4問 ABC087B - Coins

A, B, C, X = [int(input()) for i in range(4)]
print(sum(500*a+100*b+50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)))


500a+100b+50c=X (0≦a≦A, 0≦b≦B, 0≦c≦C)

第5問 ABC083B - Some Sums

N, A, B = map(int, input().split())
print(sum(i for i in range(1, N+1) if A <= sum(map(int, str(i))) <= B))


第6問 ABC088B - Card Game for Two

N = int(input())
a = sorted(map(int, input().split()))[::-1]


第7問 ABC085B - Kagami Mochi

N = int(input())
d = [input() for i in range(N)]


第8問 ABC085C - Otoshidama

N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 10000*x+5000*y+1000*z == Y:
            print(x, y, z)
print(-1, -1, -1)

【解説】下記の連立方程式を満たす x, y, z がある場合はx y zの値を出力し、満たす x, y, z がない場合は-1 -1 -1を出力します。

z=N-x-y & (0≦z≦2000) \\
10000x+5000y+1000z=Y  & (0≦x≦N, 0≦y≦N-x)

第9問 ABC049C - 白昼夢

import re
S = input()
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", S) else "NO")


第10問 ABC086C - Traveling

N = int(input())
count = 0
pt, px, py = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-px)+abs(y-py) <= t-pt and t % 2 == (x+y) % 2:
        count += 1
    pt, px, py = t, x, y
print("Yes" if count == N else "No")


|x-px|+|y-py|≦t-pt \\



Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away