0
0

Welcome to AtCoder

a = int(input())
b, c = map(int, input().split())
s = input()
print(sum([a, b, c]), s)
print(int(input()) + sum(map(int, input().split())), input())

ABC086A Product

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

ABC081A Placing Marbles

s = input()
print(sum(map(int, s)))
s = input()
print(s.count('1'))

ABC081B Shift only

n = int(input())
arr = list(map(int, input().split()))

count = 0
while all(i % 2 == 0 for i in arr):
  arr = list(map(lambda x: x // 2, arr))
  count += 1

print(count)
n = int(input())
arr = list(map(int,input().split()))

count = 0

while all(i % 2 == 0 for i in arr):
  arr = [i // 2 for i in arr]
  count += 1

print(count)

ABC087B Coins

a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a + 1):
  for j in range(b + 1):
    k = x - (500 * i + 100 * j)
    if 0 <= k // 50 <= c and k % 50 == 0:
      count += 1
print(count)

ABC083B Some Sums

n, a, b = map(int, input().split())
ans = 0
for i in range(1, n + 1):
  i_sum = sum(map(int, str(i)))
  if a <= i_sum <= b:
    ans += i
print(ans)

ABC088B Card Game for Two

n = int(input())
nums = sorted(list(map(int, input().split())), reverse=True)

if n > 1:
  a_point = sum(nums[::2])
  b_point = sum(nums[1::2])
  print(a_point - b_point)
else:
  print(nums[0])

ABC085B Kagami Mochi

n = int(input())
d_set = set([int(input()) for _ in range(n)])
print(len(d_set))

ABC085C Otoshidama

n, y = map(int, input().split())

for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - i - j
    if 10000 * i + 5000 * j + 1000 * k == y:
      print(i, j, k)
      exit()
print(-1, -1, -1)

ABC049C 白昼夢

s = input().replace('eraser', '').replace('erase', '').replace('dreamer', '').replace('dream', '')
print('YES' if s == '' else 'NO')
import re
s = input()
if re.compile(r'^(?:dream(?:er)?|eraser?)+$').search(s):
  print('YES')
else:
  print('NO')

正規表現
^は文字列の先頭、$は文字列の末尾を示す
(?: ... )は非キャプチャグループ
(?:er)はerを非キャプチャグループとして、
(?:er)?の後ろの?は0回か1回の繰り返し
|はorを示す
eraser??は手前のrが0回か1回繰り返す
+は1回以上の繰り返し
つまり、deramかdreamerかeraseかeraserが1回以上繰り返された文字列が先頭から末尾まで続いているかどうか判定することができる

ABC086C Traveling

n = int(input())
count = 0
st, sx, sy = 0, 0, 0
for i in range(n):
  t, x, y = map(int, input().split())
  if abs(x - sx) + abs(y - sy) <= t - st and (abs(x - sx) + abs(y - sy) - (t - st)) % 2 == 0:
    count += 1
  st, sx, sy = t, x, y
print('Yes' if count == n else 'No')
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0