ABC解説

AtCoder Beginner Contest 281

A. Count Down

import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    for i in range(n, -1, -1):
        print(i)


if __name__ == '__main__':
    solve()

B. Sandwich Number

import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = str(input().rstrip('\n'))
    if len(s) == 8:
        for i in range(len(s)):
            if i == 0 or i == len(s) - 1:
                if 65 <= ord(s[i]) <= 90:
                    continue
                else:
                    print("No")
                    exit()
            else:
                if 48 <= ord(s[i]) <= 57:
                    continue
                else:
                    print("No")
                    exit()
        if 100000 <= int(s[1:-1]) <= 999999:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


if __name__ == '__main__':
    solve()

C. Circular Playlist

import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, t = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    t %= sum(a)
    total = 0
    for i in range(n):
        total += a[i]
        if t <= total:
            print(i + 1, a[i] - total + t)
            exit()


if __name__ == '__main__':
    solve()

-ABC解説