Atcoderの過去問精選10問をpythonで解いてみた！

# はじめに
　Atcoder初心者です。練習のためにこの記事の問題（[AtCoder に登録したら次にやること ～ これだけ解けば十分闘える！過去問精選 10 問 ～](https://qiita.com/drken/items/fd4e5e3630d0f5859067#5-%E9%81%8E%E5%8E%BB%E5%95%8F%E7%B2%BE%E9%81%B8-10-%E5%95%8F)）をpythonで解いてみました。

## 第 1 問: [ABC 086 A - Product](https://atcoder.jp/contests/abc086/tasks/abc086_a)
```python
a, b = map(int, input().split())
if (a*b)%2 ==0:
    print('Even')
else:
    print('Odd')
```

## 第 2 問: [ABC 081 A - Placing Marbles](https://atcoder.jp/contests/abc081/tasks/abc081_a)
```python
s = input()
count = 0

for i in s:
    if i=='1':
        count += 1

print(count)
```

##### 別解1
```python
print(input().count('1'))
```

##### 別解2
```python
print(int(input()) % 9)
```

## 第 3 問: [ABC 081 B - Shift Only](https://atcoder.jp/contests/abc081/tasks/abc081_b)
```python
N = int(input())
A = list(map(int, input().split()))
count = 0

#all(): 全ての要素がTrueならTrue
#any(): 一つでもTrueならTrue
while all(a%2==0 for a in A): 
    A = [a/2 for a in A]
    count += 1
    
print(count)
```

## 第 4 問: [ABC 087 B - Coins](https://atcoder.jp/contests/abc087/tasks/abc087_b)
```python
A = int(input())
B = int(input())
C = int(input())
X = int(input())
counts = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (500*a + 100*b + 50*c) == X:
                counts += 1
                
print(counts)
```
##### 別解
```python
A, B, C, X = [int(input()) for _ in range(4)]
print([500*a + 100*b + 50*c for c in range(C+1) for b in range(B+1) for a in range(A+1)].count(X))
```
## 第 5 問: [ABC 083 B - Some Sums](https://atcoder.jp/contests/abc083/tasks/abc083_b)
```python
N, A, B = map(int, input().split())
ans = 0

def FindSumOfDigits(x):
    count = 0
    while x>0:
        count += x%10
        x = x//10
    
    return count
    
for n in range(1, N+1):
    count = FindSumOfDigits(n)
    if A<= count <=B:
        ans += n

print(ans) 
```

## 第 6 問: [ABC 088 B - Card Game for Two](https://atcoder.jp/contests/abc088/tasks/abc088_b)
```python
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
alice = bob = 0
for i in range(N):
    if i%2 == 0:
        alice += A[i]
    else:
        bob += A[i]
    
print(alice - bob)
```

## 第 7 問: [ABC 085 B - Kagami Mochi](https://atcoder.jp/contests/abc085/tasks/abc085_b)
```python
N = int(input())
d = [int(input()) for _ in range(N)]
print(len(set(d)))
```

## 第 8 問: [ABC 085 C - Otoshidama](https://atcoder.jp/contests/abc085/tasks/abc085_c)
```python
N, Y = map(int, input().split())
res10000 =res5000 = res1000 = -1

for x in range(N+1):
    for y in range(N+1-x):
        z = N-x-y # zは決まっているので、ループを減らして、計算量を減らす！
        if 10000*x + 5000*y + 1000*z == Y:
            res10000 = x
            res5000 = y
            res1000 = z

print(res10000, res5000, res1000)
```

## 第 9 問: [ABC 049 C - Daydream](https://atcoder.jp/contests/abc049/tasks/arc065_a)
```python
import re
S = input()
'''
メタ文字：
^ = 文字列の先頭、
| = OR
+ = 直前のパターンを1回以上繰り返し、
$ = 文字列の末尾
'''
if re.match("^(dream|dreamer|erase|eraser)+$", S):
    print('YES')
else:
    print('NO')
```

## 第 10 問: [ABC 086 C - Traveling](https://atcoder.jp/contests/abc086/tasks/arc089_a)
```python
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(N):
    t[i+1], x[i+1], y[i+1] = map(int, input().split())
    
f = True
for i in range(N):
    dt = t[i+1] - t[i]
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    if dt < dist:
        f = False
    if dist%2 != dt%2:
        f = False

print('Yes' if f else 'No')
```